Upload folder using huggingface_hub
Browse files
chat.py
CHANGED
@@ -29,12 +29,13 @@ assistant = client.beta.assistants.create(name="Patient Sim", instructions=instr
|
|
29 |
toggle_js = open("toggle_speech.js").read()
|
30 |
|
31 |
def start_thread():
|
|
|
32 |
return client.beta.threads.create()
|
33 |
|
34 |
def user(text, audio, history, thread):
|
35 |
if audio:
|
36 |
text = transcribe(audio)
|
37 |
-
print(
|
38 |
message = client.beta.threads.messages.create(thread_id=thread.id, role="user", content=text)
|
39 |
return "", history + [[text, None]]
|
40 |
|
@@ -61,6 +62,7 @@ def transcribe(file):
|
|
61 |
|
62 |
def speak(history):
|
63 |
text = history[-1][1]
|
|
|
64 |
speech = client.audio.speech.create(model="tts-1", voice="alloy", input=text)
|
65 |
data, sr = sf.read(BytesIO(speech.read()), dtype='int16')
|
66 |
return sr, data
|
|
|
29 |
toggle_js = open("toggle_speech.js").read()
|
30 |
|
31 |
def start_thread():
|
32 |
+
print("start_thread")
|
33 |
return client.beta.threads.create()
|
34 |
|
35 |
def user(text, audio, history, thread):
|
36 |
if audio:
|
37 |
text = transcribe(audio)
|
38 |
+
print("User:", text)
|
39 |
message = client.beta.threads.messages.create(thread_id=thread.id, role="user", content=text)
|
40 |
return "", history + [[text, None]]
|
41 |
|
|
|
62 |
|
63 |
def speak(history):
|
64 |
text = history[-1][1]
|
65 |
+
print("Assistant:", text)
|
66 |
speech = client.audio.speech.create(model="tts-1", voice="alloy", input=text)
|
67 |
data, sr = sf.read(BytesIO(speech.read()), dtype='int16')
|
68 |
return sr, data
|