Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,6 @@ import gradio as gr
|
|
5 |
|
6 |
openai.api_key = "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"
|
7 |
|
8 |
-
|
9 |
import requests
|
10 |
|
11 |
API_URL = "https://api-inference.huggingface.co/models/lyimo/whisper-small-sw2"
|
@@ -17,7 +16,6 @@ def query(filename):
|
|
17 |
response = requests.post(API_URL, headers=headers, data=data)
|
18 |
return response.json()
|
19 |
|
20 |
-
|
21 |
def transcribe(audio):
|
22 |
with open(audio, "rb") as audio_file:
|
23 |
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|
@@ -55,14 +53,14 @@ def process_audio_and_respond(audio):
|
|
55 |
text = transcribe(audio)
|
56 |
response_text = generate_response(text)
|
57 |
output_file = inference(response_text)
|
58 |
-
return
|
59 |
|
60 |
demo = gr.Interface(
|
61 |
process_audio_and_respond,
|
62 |
-
gr.inputs.Audio(source="microphone", type="filepath", label="
|
63 |
-
|
64 |
-
title="
|
65 |
-
description="
|
66 |
theme="compact",
|
67 |
layout="vertical",
|
68 |
allow_flagging=False,
|
|
|
5 |
|
6 |
openai.api_key = "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"
|
7 |
|
|
|
8 |
import requests
|
9 |
|
10 |
API_URL = "https://api-inference.huggingface.co/models/lyimo/whisper-small-sw2"
|
|
|
16 |
response = requests.post(API_URL, headers=headers, data=data)
|
17 |
return response.json()
|
18 |
|
|
|
19 |
def transcribe(audio):
|
20 |
with open(audio, "rb") as audio_file:
|
21 |
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|
|
|
53 |
text = transcribe(audio)
|
54 |
response_text = generate_response(text)
|
55 |
output_file = inference(response_text)
|
56 |
+
return output_file
|
57 |
|
58 |
demo = gr.Interface(
|
59 |
process_audio_and_respond,
|
60 |
+
gr.inputs.Audio(source="microphone", type="filepath", label="Bofya Kuuliza Swali"),
|
61 |
+
gr.outputs.Audio(type="filepath", label="Bofya Kusikiliza Jibu"),
|
62 |
+
title="Uliza Mtaalamu wa Viazi Lishe",
|
63 |
+
description="Je ungependa Kujua nini kuhusu viazi Lishe?",
|
64 |
theme="compact",
|
65 |
layout="vertical",
|
66 |
allow_flagging=False,
|