garyd1 commited on
Commit
a04df1c
·
verified ·
1 Parent(s): 245bbab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -4,14 +4,11 @@ from transformers import pipeline
4
  from sentence_transformers import SentenceTransformer
5
  from sklearn.metrics.pairwise import cosine_similarity
6
  import PyPDF2
7
- from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
8
-
9
- # Load models for TTS from Hugging Face Hub
10
- models, cfg, task = load_model_ensemble_and_task_from_hf_hub("facebook/fastspeech2-en-ljspeech")
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,10 +47,9 @@ def generate_question(user_input, resume_embeddings):
50
 
51
  # Generate TTS output
52
  def generate_audio(text):
53
- """Convert text to audio using Fairseq TTS model."""
54
- # Here you can integrate model-specific logic to produce audio from text
55
- # Placeholder return until Fairseq TTS model logic is implemented
56
- return text # Replace with actual waveform generation
57
 
58
  # Gradio interface
59
  class MockInterview:
 
4
  from sentence_transformers import SentenceTransformer
5
  from sklearn.metrics.pairwise import cosine_similarity
6
  import PyPDF2
 
 
 
 
7
 
8
  # Load local models for inference
9
  stt_model = pipeline("automatic-speech-recognition", model="openai/whisper-base")
10
  conversation_model = pipeline("text-generation", model="facebook/blenderbot-400M-distill")
11
+ tts_model = pipeline("text-to-speech", model="facebook/fastspeech2-en-ljspeech")
12
 
13
  # Load a pre-trained model for vector embeddings
14
  embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
 
47
 
48
  # Generate TTS output
49
  def generate_audio(text):
50
+ """Convert text to audio using Hugging Face TTS model."""
51
+ audio_data = tts_model(text, return_tensors=True)["waveform"]
52
+ return audio_data
 
53
 
54
  # Gradio interface
55
  class MockInterview: