Update app.py
Browse files
app.py
CHANGED
@@ -4,13 +4,14 @@ from transformers import pipeline
|
|
4 |
from sentence_transformers import SentenceTransformer
|
5 |
from sklearn.metrics.pairwise import cosine_similarity
|
6 |
import PyPDF2
|
7 |
-
import
|
8 |
-
|
|
|
|
|
9 |
|
10 |
# Load local models for inference
|
11 |
-
stt_model = pipeline("automatic-speech-recognition", model="openai/whisper-
|
12 |
-
conversation_model = pipeline("text-generation", model="facebook/blenderbot-400M-distill"
|
13 |
-
tts_model = pipeline("text-to-speech", model="facebook/fastspeech2-en-ljspeech", torch_dtype=torch.float16)
|
14 |
|
15 |
# Load a pre-trained model for vector embeddings
|
16 |
embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
|
@@ -49,9 +50,10 @@ def generate_question(user_input, resume_embeddings):
|
|
49 |
|
50 |
# Generate TTS output
|
51 |
def generate_audio(text):
|
52 |
-
"""Convert text to audio using
|
53 |
-
|
54 |
-
|
|
|
55 |
|
56 |
# Gradio interface
|
57 |
class MockInterview:
|
@@ -120,4 +122,4 @@ Upload your resume and job description, then engage in a realistic audio-based i
|
|
120 |
end_button.click(end_interview, outputs=[transcription_output, question_output])
|
121 |
|
122 |
if __name__ == "__main__":
|
123 |
-
interface.launch()
|
|
|
4 |
from sentence_transformers import SentenceTransformer
|
5 |
from sklearn.metrics.pairwise import cosine_similarity
|
6 |
import PyPDF2
|
7 |
+
from TTS.api import TTS # Coqui TTS library
|
8 |
+
|
9 |
+
# Initialize TTS model
|
10 |
+
tts_model = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC", progress_bar=False, gpu=False)
|
11 |
|
12 |
# Load local models for inference
|
13 |
+
stt_model = pipeline("automatic-speech-recognition", model="openai/whisper-base")
|
14 |
+
conversation_model = pipeline("text-generation", model="facebook/blenderbot-400M-distill")
|
|
|
15 |
|
16 |
# Load a pre-trained model for vector embeddings
|
17 |
embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
|
|
|
50 |
|
51 |
# Generate TTS output
|
52 |
def generate_audio(text):
|
53 |
+
"""Convert text to audio using Coqui TTS."""
|
54 |
+
audio_path = "output.wav"
|
55 |
+
tts_model.tts_to_file(text=text, file_path=audio_path)
|
56 |
+
return audio_path
|
57 |
|
58 |
# Gradio interface
|
59 |
class MockInterview:
|
|
|
122 |
end_button.click(end_interview, outputs=[transcription_output, question_output])
|
123 |
|
124 |
if __name__ == "__main__":
|
125 |
+
interface.launch()
|