Spaces:
Runtime error
Runtime error
File size: 1,248 Bytes
1c82b7f 0cce4e4 1c82b7f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import requests
import gradio as gr
import os
import requests
GLADIA_API_KEY = os.environ.get('GLADIA_API_KEY')
headers = {
'accept': 'application/json',
'x-gladia-key': GLADIA_API_KEY,
}
ACCEPTED_LANGUAGE_BEHAVIOUR = [
'manual',
'automatic single language',
'automatic mul language',
]
def greet(audio, language_behaviour, Language: str):
files = {
'audio': ("colors.wav", open(audio, 'rb'), 'audio/wav'),
'language': (None, Language),
'language_behaviour': (None, language_behaviour),
}
response = requests.post(
'https://api.gladia.io/audio/text/audio-transcription/',
headers=headers,
files=files
)
if response.status_code != 200:
print(response.content, response.status_code)
return "Sorry, an error occured with you request :/"
return response.json()["prediction"]
iface = gr.Interface(
fn=greet,
inputs=[
gr.Audio(source="upload", type="filepath"),
gr.Dropdown(
choices=ACCEPTED_LANGUAGE_BEHAVIOUR,
value=ACCEPTED_LANGUAGE_BEHAVIOUR[1],
type="value",
),
gr.Textbox(placeholder="english", max_lines=1),
],
outputs="json"
)
iface.launch()
|