2 Commits

Author SHA1 Message Date
bel
0aff4f556b one more 2023-04-08 20:05:03 -06:00
bel
88bf54d022 url replaces hotword,context too 2023-04-02 10:48:41 -06:00

View File

@@ -136,7 +136,7 @@ class Parser(threading.Thread):
p = "/tmp/whisper-cpp.wav"
with open("/tmp/whisper-cpp.wav", "wb") as f:
f.write(wav)
proc = subprocess.run(f"MODEL=./models/ggml-{os.environ.get('MODEL','tiny.en')}.bin WAV={p} P=2 rust-whisper", capture_output=True, shell=True)
proc = subprocess.run(f"MODEL=./models/ggml-{os.environ.get('MODEL','tiny.en')}.bin WAV={p} P={os.environ.get('P', '2')} rust-whisper", capture_output=True, shell=True)
result = proc.stdout.decode().strip()
if os.environ.get("DEBUG", None):
log("stderr:", proc.stderr.decode().strip())
@@ -144,6 +144,7 @@ class Parser(threading.Thread):
result = result.replace(">>", "")
result = "".join([i.split("]")[-1] for i in result.split("[")[0]])
result = "".join([i.split(")")[-1] for i in result.split("(")[0]])
result = "".join([i.split(">")[-1] for i in result.split("<")[0]])
if os.environ.get("DEBUG", None):
log("annotation-free transcript:", result)
return result
@@ -319,9 +320,12 @@ class Actor(threading.Thread):
body = self.body
body = body.replace("{{hotword}}", hotword)
body = body.replace("{{context}}", context)
url = self.url
url = url.replace("{{hotword}}", hotword)
url = url.replace("{{context}}", context)
if os.environ.get("DEBUG", "") :
log("POST", self.url, headers, body)
requests.post(self.url, headers=headers, data=body)
log("POST", url, headers, body)
requests.post(url, headers=headers, data=body)
except Exception as e:
log("Actor.handle_url:", e)