storage / ASR /demo.py
darshanmakwana's picture
Upload folder using huggingface_hub
e0c2d04 verified
raw
history blame contribute delete
865 Bytes
from flask import Flask, request
# import speech_recognition as sr
app = Flask(__name__)
# recognizer = sr.Recognizer()
@app.route("/darshan/microphone", methods=['POST'])
def handle_audio():
audio_data = request.data
print(audio_data)
# audio = sr.AudioData(audio_data, sample_rate=44100, sample_width=2) # Adjust sample rate and sample width as needed
# try:
# text = recognizer.recognize_google(audio)
# print(f"Transcription: {text}")
# return {'transcription': text}, 200
# except sr.UnknownValueError:
# print("Could not understand audio")
# return '', 400
# except sr.RequestError as e:
# print(f"Error from Google Speech Recognition service; {e}")
# return '', 500
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8723) # Replace with your desired host and port