Spaces:
Runtime error
Runtime error
Create first version of app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import sounddevice as sd
|
3 |
+
import soundfile as sf
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
|
7 |
+
API_URL = "https://api-inference.huggingface.co/models/BenDaouda/wav2vec2-large-xls-r-300m-wolof-test-coloab"
|
8 |
+
headers = {"Authorization": "Bearer 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"}
|
9 |
+
|
10 |
+
def query(filename):
|
11 |
+
with open(filename, "rb") as f:
|
12 |
+
data = f.read()
|
13 |
+
response = requests.post(API_URL, headers=headers, data=data)
|
14 |
+
return response.json()
|
15 |
+
|
16 |
+
|
17 |
+
iface = gr.Interface(fn=query,inputs=gr.Audio(source="microphone", type="filepath"),output="text")
|
18 |
+
|
19 |
+
iface.launch()
|