File size: 923 Bytes
67965ba
9e8a040
320e714
67965ba
9f95d71
f808091
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9ace33
8c8ff11
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
import os 
import gradio as gr
os.system("sudo apt-get update")
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="upload", type="filepath"), outputs="text")
k.launch()