Spaces:
Sleeping
Sleeping
import os | |
os.system("apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg") | |
import sounddevice as sd | |
import speech_recognition as sr | |
def takeCommand(audio): | |
r = sr.Recognizer() | |
with sr.AudioFile( | |
audio | |
) as source: # Replace "audio.wav" with the path to your .wav file | |
# print("Listening...") | |
audio_data = r.record(source) | |
try: | |
# print("Recognizing...") | |
query = r.recognize_google(audio_data, language="en-in") | |
print(f"User said: {query}") | |
return query | |
except sr.UnknownValueError: | |
print("Unable to recognize speech") | |
except sr.RequestError as e: | |
print(f"Error occurred: {e}") | |
return "Some error occurred. Sorry from Jarvis" | |
k=gr.Interface(fn=takeCommand, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text") | |
k.launch() |