Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from __future__ import print_function
from object_watcher.object_watcher import ObjectWatcher
from object_watcher.object_watcher import create_dlib_frontal_face_detector
from simple_audio_recorder.simple_audio_recorder import SimpleAudioRecorder
from stt.simple_stt import SimpleSTT
from websocket import create_connection
import json
import time
import traceback
transcriber = SimpleSTT()
URL_TEMPLATE = "{scheme}://{host}:{port}{path}"
def send_message(message, host="localhost", port=8181, path="/core", scheme="ws"):
payload = json.dumps({
"type": "recognizer_loop:utterance",
"context": "",
"data": {
"utterances": [message]
}
})
url = URL_TEMPLATE.format(scheme=scheme, host=host, port=str(port), path=path)
ws = create_connection(url)
ws.send(payload)
ws.close()