Spaces:
Sleeping
Sleeping
Update pages/🧠_sickle_cell_chatbot.py
Browse files
pages/🧠_sickle_cell_chatbot.py
CHANGED
|
@@ -104,13 +104,13 @@ class ContextChatbot:
|
|
| 104 |
)
|
| 105 |
return qa
|
| 106 |
|
| 107 |
-
def transcribe_audio(audio_bytes):
|
| 108 |
response = self.openai_model.audio.transcriptions.create(
|
| 109 |
model="whisper-1",
|
| 110 |
file=("temp." + "wav", audio_bytes, "audio/wav"),
|
| 111 |
)
|
| 112 |
|
| 113 |
-
|
| 114 |
|
| 115 |
@utils.enable_chat_history
|
| 116 |
def main(self):
|
|
@@ -119,7 +119,7 @@ class ContextChatbot:
|
|
| 119 |
chain = self.setup_chain()
|
| 120 |
user_query = st.chat_input(placeholder="Ask me anything!")
|
| 121 |
if audio_bytes:
|
| 122 |
-
transcript = transcribe_audio(audio_bytes)
|
| 123 |
if transcript:
|
| 124 |
question = transcript
|
| 125 |
utils.display_msg(question, 'user')
|
|
|
|
| 104 |
)
|
| 105 |
return qa
|
| 106 |
|
| 107 |
+
def transcribe_audio(self, audio_bytes):
|
| 108 |
response = self.openai_model.audio.transcriptions.create(
|
| 109 |
model="whisper-1",
|
| 110 |
file=("temp." + "wav", audio_bytes, "audio/wav"),
|
| 111 |
)
|
| 112 |
|
| 113 |
+
return response.text
|
| 114 |
|
| 115 |
@utils.enable_chat_history
|
| 116 |
def main(self):
|
|
|
|
| 119 |
chain = self.setup_chain()
|
| 120 |
user_query = st.chat_input(placeholder="Ask me anything!")
|
| 121 |
if audio_bytes:
|
| 122 |
+
transcript = self.transcribe_audio(audio_bytes)
|
| 123 |
if transcript:
|
| 124 |
question = transcript
|
| 125 |
utils.display_msg(question, 'user')
|