-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudioappsave2.py
51 lines (31 loc) · 1.26 KB
/
audioappsave2.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from flask import Flask, request, render_template
# Importing whisper to control audio
import whisper
model = whisper.load_model("base")
# Importing the question answering bot
from answer_generator import question_answering_bot
app = Flask(__name__)
@app.route('/')
def index():
return render_template('saving.html',transcription="Testing")
@app.route('/upload-audio', methods=['POST','GET'])
def upload_audio():
audio_file = request.files['audio']
# Save the audio file to a desired location
audio_file.save('audio.wav')
text_from_audio = model.transcribe("audio.wav")
transcription = text_from_audio["text"]
global transcription_data, reply
transcription_data = transcription
llm_output = question_answering_bot(transcription_data)
reply = llm_output["results"]
print(reply)
print(transcription)
return "Audio input successful"
@app.route('/transcription')
def get_transcription():
if(transcription_data==None):
return render_template('saving.html',transcription="Ask me anything")
return render_template('saving.html',transcription=transcription_data, reply = reply)
if __name__ == '__main__':
app.run()