-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterviewerTest.py
More file actions
64 lines (49 loc) · 1.57 KB
/
Copy pathInterviewerTest.py
File metadata and controls
64 lines (49 loc) · 1.57 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
from flask import Flask, render_template, request, jsonify, send_from_directory
from utils.groq_llm import ask_groq
from utils.tts import text_to_speech
from utils.stt import speech_to_text
import os
app = Flask(__name__)
# Serve generated audio files from static/audio
@app.route('/static/audio/<filename>')
def serve_audio(filename):
return send_from_directory('static/audio', filename)
# Landing page
@app.route('/')
def index():
return render_template('index.html')
# Interviewer chat page
@app.route('/interview')
def interview():
return render_template('interview.html')
# Handle text input in interview chat
@app.route('/send_message', methods=['POST'])
def send_message():
user_input = request.json.get('message')
# Get response from Groq LLM
ai_response = ask_groq(user_input)
# Convert response to speech
audio_path = text_to_speech(ai_response)
return jsonify({
'response': ai_response,
'audio_url': audio_path
})
# Handle audio input in interview chat
@app.route('/audio_input', methods=['POST'])
def audio_input():
audio_file = request.files['audio']
# Convert audio to text
user_text = speech_to_text(audio_file)
# Get LLM response
ai_response = ask_groq(user_text)
# Convert response to speech
audio_path = text_to_speech(ai_response)
return jsonify({
'user_text': user_text,
'response': ai_response,
'audio_url': audio_path
})
if __name__ == '__main__':
if not os.path.exists('static/audio'):
os.makedirs('static/audio')
app.run(debug=True)