Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -171,6 +171,7 @@ class BasicAgent:
|
|
171 |
def _transcribe_audio(self, audio_bytes: bytes) -> str:
|
172 |
audio_file = BytesIO(audio_bytes)
|
173 |
transcription = self.client.audio.transcriptions.create(model="whisper-1", file=audio_file)
|
|
|
174 |
return transcription.text.strip()
|
175 |
|
176 |
def _load_image(self, data: str) -> Image.Image:
|
@@ -232,7 +233,7 @@ def get_or_download_image(file_name: str) -> Image.Image:
|
|
232 |
full_url = f"{base_url}/{commit_hash}/2023/validation/{file_name}"
|
233 |
'''
|
234 |
|
235 |
-
DOMANDE_MOCKATE =
|
236 |
def create_mock_questions():
|
237 |
|
238 |
'''
|
@@ -242,13 +243,23 @@ def create_mock_questions():
|
|
242 |
"Level":"1",
|
243 |
"file_name":"cca530fc-4052-43b2-b130-b30968d8aa44.png"
|
244 |
},
|
245 |
-
|
246 |
-
|
247 |
-
return [
|
248 |
-
{'task_id': '8e867cd7-cff9-4e6c-867a-ff5ddc2550be',
|
249 |
'question': 'How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.',
|
250 |
'Level': '1',
|
251 |
'file_name': ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
}
|
253 |
]
|
254 |
|
@@ -264,6 +275,8 @@ def transcribe_audio(file_name: str) -> str:
|
|
264 |
|
265 |
model = whisper.load_model("base")
|
266 |
result = model.transcribe(file_path)
|
|
|
|
|
267 |
return result["text"]
|
268 |
|
269 |
|
|
|
171 |
def _transcribe_audio(self, audio_bytes: bytes) -> str:
|
172 |
audio_file = BytesIO(audio_bytes)
|
173 |
transcription = self.client.audio.transcriptions.create(model="whisper-1", file=audio_file)
|
174 |
+
print_coso(f"usato _transcribe_audio: {transcription}")
|
175 |
return transcription.text.strip()
|
176 |
|
177 |
def _load_image(self, data: str) -> Image.Image:
|
|
|
233 |
full_url = f"{base_url}/{commit_hash}/2023/validation/{file_name}"
|
234 |
'''
|
235 |
|
236 |
+
DOMANDE_MOCKATE = True
|
237 |
def create_mock_questions():
|
238 |
|
239 |
'''
|
|
|
243 |
"Level":"1",
|
244 |
"file_name":"cca530fc-4052-43b2-b130-b30968d8aa44.png"
|
245 |
},
|
246 |
+
|
247 |
+
{'task_id': '8e867cd7-cff9-4e6c-867a-ff5ddc2550be',
|
|
|
|
|
248 |
'question': 'How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.',
|
249 |
'Level': '1',
|
250 |
'file_name': ''
|
251 |
+
}
|
252 |
+
'''
|
253 |
+
|
254 |
+
|
255 |
+
|
256 |
+
|
257 |
+
|
258 |
+
return [
|
259 |
+
{'task_id': '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3',
|
260 |
+
'question': 'Hi, I\'m making a pie but I could use some help with my shopping list. I have everything I need for the crust, but I\'m not sure about the filling. I got the recipe from my friend Aditi, but she left it as a voice memo and the speaker on my phone is buzzing so I can\'t quite make out what she\'s saying. Could you please listen to the recipe and list all of the ingredients that my friend described? I only want the ingredients for the filling, as I have everything I need to make my favorite pie crust. I\'ve attached the recipe as Strawberry pie.mp3.\n\nIn your response, please only list the ingredients, not any measurements. So if the recipe calls for "a pinch of salt" or "two cups of ripe strawberries" the ingredients on the list would be "salt" and "ripe strawberries".\n\nPlease format your response as a comma separated list of ingredients. Also, please alphabetize the ingredients.',
|
261 |
+
'Level': '1',
|
262 |
+
'file_name': '99c9cc74-fdc8-46c6-8f8d-3ce2d3bfeea3.mp3'
|
263 |
}
|
264 |
]
|
265 |
|
|
|
275 |
|
276 |
model = whisper.load_model("base")
|
277 |
result = model.transcribe(file_path)
|
278 |
+
|
279 |
+
print_coso(f"usato transcribe_audio tool: {result["text"]}")
|
280 |
return result["text"]
|
281 |
|
282 |
|