File size: 865 Bytes
e0c2d04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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