latuan commited on
Commit
03c98a5
1 Parent(s): c78175c
Files changed (2) hide show
  1. app.py +3 -5
  2. requirements.txt +2 -1
app.py CHANGED
@@ -2,6 +2,7 @@ import os
2
  import re
3
  import io
4
  import torch
 
5
  import zipfile
6
  import requests
7
  import torchaudio
@@ -10,7 +11,6 @@ import gradio as gr
10
  from uroman import uroman
11
  import concurrent.futures
12
  from pydub import AudioSegment
13
- from pydub.effects import speedup
14
  from datasets import load_dataset
15
  from IPython.display import Audio
16
  from scipy.signal import butter, lfilter
@@ -188,10 +188,8 @@ def generate_audio_with_pause(srt_file_path):
188
  # Adjust audio speed by speedup
189
  if desired_duration < current_duration:
190
  speedup_factor = current_duration / desired_duration
191
- audio_data_list = audio_data.tolist()
192
- audio_data_list = speedup(audio_data_list, playback_speed=speedup_factor)
193
- audio_data = np.array(audio_data_list)
194
-
195
  audio_clips.append(audio_data)
196
 
197
  # Add pause
 
2
  import re
3
  import io
4
  import torch
5
+ import librosa
6
  import zipfile
7
  import requests
8
  import torchaudio
 
11
  from uroman import uroman
12
  import concurrent.futures
13
  from pydub import AudioSegment
 
14
  from datasets import load_dataset
15
  from IPython.display import Audio
16
  from scipy.signal import butter, lfilter
 
188
  # Adjust audio speed by speedup
189
  if desired_duration < current_duration:
190
  speedup_factor = current_duration / desired_duration
191
+ audio_data = librosa.effects.time_stretch(audio_data, speedup_factor)
192
+
 
 
193
  audio_clips.append(audio_data)
194
 
195
  # Add pause
requirements.txt CHANGED
@@ -9,4 +9,5 @@ librosa==0.10.0
9
  pydub==0.25.1
10
  speechbrain==0.5.16
11
  moviepy
12
- IPython
 
 
9
  pydub==0.25.1
10
  speechbrain==0.5.16
11
  moviepy
12
+ IPython
13
+ librosa