husseinelsaadi commited on
Commit
5cc76cc
·
verified ·
1 Parent(s): 844edfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -1483,7 +1483,7 @@ def bark_tts(text):
1483
  print(f"🔁 Synthesizing TTS for: {text}")
1484
  inputs = processor_bark(text, return_tensors="pt", voice_preset=bark_voice_preset)
1485
  inputs = {k: v.to(model_bark.device) for k, v in inputs.items()}
1486
- speech_values = model_bark.generate(**inputs, max_new_tokens=300)
1487
  speech = speech_values.cpu().numpy().squeeze()
1488
  speech = (speech * 32767).astype(np.int16)
1489
  temp_wav = tempfile.NamedTemporaryFile(delete=False, suffix=".wav")
@@ -1623,7 +1623,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
1623
 
1624
 
1625
  state["conversation_history"].append({'role': 'Interviewer', 'content': first_q})
 
1626
  audio_path = bark_tts(first_q)
 
 
1627
  # LOG
1628
  state["log"].append({"type": "question", "question": first_q, "question_eval": q_eval, "timestamp": time.time()})
1629
  return state, gr.update(visible=False), gr.update(visible=True), audio_path, f"*Question 1:* {first_q}"
 
1483
  print(f"🔁 Synthesizing TTS for: {text}")
1484
  inputs = processor_bark(text, return_tensors="pt", voice_preset=bark_voice_preset)
1485
  inputs = {k: v.to(model_bark.device) for k, v in inputs.items()}
1486
+ speech_values = model_bark.generate(**inputs, max_new_tokens=100)
1487
  speech = speech_values.cpu().numpy().squeeze()
1488
  speech = (speech * 32767).astype(np.int16)
1489
  temp_wav = tempfile.NamedTemporaryFile(delete=False, suffix=".wav")
 
1623
 
1624
 
1625
  state["conversation_history"].append({'role': 'Interviewer', 'content': first_q})
1626
+ start = time.perf_counter()
1627
  audio_path = bark_tts(first_q)
1628
+ print("⏱️ Bark TTS took", time.perf_counter() - start, "seconds")
1629
+
1630
  # LOG
1631
  state["log"].append({"type": "question", "question": first_q, "question_eval": q_eval, "timestamp": time.time()})
1632
  return state, gr.update(visible=False), gr.update(visible=True), audio_path, f"*Question 1:* {first_q}"