File size: 563 Bytes
1f855d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import requests
import sounddevice as sd
import soundfile as sf
import gradio as gr


API_URL = "https://api-inference.huggingface.co/models/BenDaouda/wav2vec2-large-xls-r-300m-wolof-test-coloab"
headers = {"Authorization": "Bearer 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"}

def query(filename):
    with open(filename, "rb") as f:
        data = f.read()
    response = requests.post(API_URL, headers=headers, data=data)
    return response.json()


iface = gr.Interface(fn=query,inputs=gr.Audio(source="microphone", type="filepath"),output="text")

iface.launch()