import speech_recognition as sr import streamlit as st # app = Flask (__name__) # @app.route('/audio',methods=['GET','POST']) # a = request.files['file'] # print(a) st.title("Urdu SR") upfile = st.file_uploader("Choose a Audio file",type=['.mp3', '.wav', '.ogg','.raw','.flac','.3gp','.3g']) if upfile != None: st.write(upfile) with sr.AudioFile(upfile) as source: r = sr.Recognizer() audio = r.record(source) try: text = r.recognize_google(audio,language='ur') st.write(text) except sr.UnknownValueError: print("Google Speech Recognition could not understand audio") except sr.RequestError as e: print("Could not request results from Google Speech Recognition service; {0}".format(e))