Spaces:
Build error
Build error
File size: 1,479 Bytes
1c8084f 199a359 ad0b7d3 1c8084f ad0b7d3 1c8084f ad0b7d3 199a359 |
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 |
import speech_recognition as sr
from googletrans import Translator
#from httpcore import SyncHTTPProxy
"""
http_proxy = SyncHTTPProxy((b'http', b'myproxy.com', 8080, b''))
proxies = {'http': http_proxy, 'https': http_proxy }
def transcribeHindi():
r = sr.Recognizer()
with sr.Microphone() as source:
# seconds of non-speaking audio before
# a phrase is considered complete
print('Listening')
r.pause_threshold = 0.7
audio = r.listen(source)
try:
print("Recognizing")
Query = r.recognize_google(audio, language='hi-In')
# for listening the command in indian english
print("the query is printed='", Query, "'")
# handling the exception, so that assistant can
# ask for telling again the command
except Exception as e:
print(e)
print("Say that again sir")
return "None"
return Query
def translate():
query = transcribeHindi()
translator = Translator()
translation = translator.translate(query, dest='en')
return translation.text
gr.Interface(
fn=translate,
inputs=gr.Audio(source="microphone", type="numpy"), outputs="text").launch()
"""
def transcribe(audio):
text = p(audio)["text"]
return text
gr.Interface(
fn=transcribe,
inputs=gr.Audio(source="microphone", type="filepath"),
outputs="text").launch() |