salomonsky commited on
Commit
31a303b
·
verified ·
1 Parent(s): c48dd31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -8
app.py CHANGED
@@ -5,7 +5,6 @@ from huggingface_hub import InferenceClient
5
  from gtts import gTTS
6
  from audiorecorder import audiorecorder
7
  import speech_recognition as sr
8
- from pydub import AudioSegment
9
 
10
  pre_prompt_text = "You are a behavioral AI, your answers should be brief, stoic and humanistic."
11
 
@@ -77,17 +76,12 @@ def generate(audio_text, history, temperature=None, max_new_tokens=512, top_p=0.
77
  audio_file = text_to_speech(response, speed=1.3)
78
  return response, audio_file
79
 
80
- def text_to_speech(text, speed=1.3):
81
  tts = gTTS(text=text, lang='es')
82
  audio_fp = io.BytesIO()
83
  tts.write_to_fp(audio_fp)
84
  audio_fp.seek(0)
85
- audio = AudioSegment.from_file(audio_fp, format="mp3")
86
- modified_speed_audio = audio.speedup(playback_speed=speed)
87
- modified_audio_fp = io.BytesIO()
88
- modified_speed_audio.export(modified_audio_fp, format="mp3")
89
- modified_audio_fp.seek(0)
90
- return modified_audio_fp
91
 
92
  def main():
93
  audio_data = audiorecorder("Push to Talk", "Stop Recording...")
 
5
  from gtts import gTTS
6
  from audiorecorder import audiorecorder
7
  import speech_recognition as sr
 
8
 
9
  pre_prompt_text = "You are a behavioral AI, your answers should be brief, stoic and humanistic."
10
 
 
76
  audio_file = text_to_speech(response, speed=1.3)
77
  return response, audio_file
78
 
79
+ def text_to_speech(text):
80
  tts = gTTS(text=text, lang='es')
81
  audio_fp = io.BytesIO()
82
  tts.write_to_fp(audio_fp)
83
  audio_fp.seek(0)
84
+ return audio_fp
 
 
 
 
 
85
 
86
  def main():
87
  audio_data = audiorecorder("Push to Talk", "Stop Recording...")