Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -29,7 +29,12 @@ def botResponse(user_input):
|
|
29 |
system_message = response["choices"][0]["message"]["content"]
|
30 |
messages.append({"role": "assistant", "content": system_message})
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
def giveVoice(bot_message):
|
35 |
myobj = gTTS(text=bot_message)
|
@@ -40,11 +45,6 @@ def giveVoice(bot_message):
|
|
40 |
|
41 |
return new_path
|
42 |
|
43 |
-
def keepLog(gpt):
|
44 |
-
|
45 |
-
|
46 |
-
return "gpt"
|
47 |
-
|
48 |
|
49 |
|
50 |
with gr.Blocks() as demo:
|
@@ -54,13 +54,11 @@ with gr.Blocks() as demo:
|
|
54 |
submit_btn = gr.Button(value="Transcribe")
|
55 |
with gr.Column():
|
56 |
user_transcript = gr.Text(label="User Transcript")
|
57 |
-
gpt_transcript = gr.Text(label="
|
58 |
gpt_voice = gr.Audio(label="Voice Response")
|
59 |
-
chat_log = gr.Text(label="Chat Log")
|
60 |
submit_btn.click(transcribe, inputs=user_audio, outputs=user_transcript)
|
61 |
user_transcript.change(botResponse, inputs=user_transcript, outputs=gpt_transcript)
|
62 |
gpt_transcript.change(giveVoice, inputs=gpt_transcript, outputs=gpt_voice)
|
63 |
-
gpt_voice.change(keepLog, inputs=user_transcript, outputs=chat_log)
|
64 |
|
65 |
|
66 |
|
|
|
29 |
system_message = response["choices"][0]["message"]["content"]
|
30 |
messages.append({"role": "assistant", "content": system_message})
|
31 |
|
32 |
+
chat_transcript = ""
|
33 |
+
for message in msg_contents:
|
34 |
+
if (message["role"] != "system"):
|
35 |
+
chat_transcript += message["role"] + ": " + message["content"] + "\n\n"
|
36 |
+
|
37 |
+
return chat_transcript
|
38 |
|
39 |
def giveVoice(bot_message):
|
40 |
myobj = gTTS(text=bot_message)
|
|
|
45 |
|
46 |
return new_path
|
47 |
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
|
50 |
with gr.Blocks() as demo:
|
|
|
54 |
submit_btn = gr.Button(value="Transcribe")
|
55 |
with gr.Column():
|
56 |
user_transcript = gr.Text(label="User Transcript")
|
57 |
+
gpt_transcript = gr.Text(label="Chat Transcript")
|
58 |
gpt_voice = gr.Audio(label="Voice Response")
|
|
|
59 |
submit_btn.click(transcribe, inputs=user_audio, outputs=user_transcript)
|
60 |
user_transcript.change(botResponse, inputs=user_transcript, outputs=gpt_transcript)
|
61 |
gpt_transcript.change(giveVoice, inputs=gpt_transcript, outputs=gpt_voice)
|
|
|
62 |
|
63 |
|
64 |
|