Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,8 @@ from datasets import load_dataset
|
|
5 |
import librosa
|
6 |
from transformers import SpeechT5ForTextToSpeech, SpeechT5HifiGan, SpeechT5Processor, pipeline
|
7 |
|
8 |
-
|
|
|
9 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
10 |
|
11 |
# load speech translation checkpoint
|
@@ -40,8 +41,8 @@ def speech_to_speech_translation(audio):
|
|
40 |
data_16 = librosa.resample(data_array, orig_sr=samplerate, target_sr=sampling_rate)
|
41 |
translated_text = translate(data_16)
|
42 |
synthesised_speech = synthesise(translated_text)
|
43 |
-
synthesised_speech = (synthesised_speech.numpy() *
|
44 |
-
return
|
45 |
|
46 |
|
47 |
title = "Cascaded STST"
|
|
|
5 |
import librosa
|
6 |
from transformers import SpeechT5ForTextToSpeech, SpeechT5HifiGan, SpeechT5Processor, pipeline
|
7 |
|
8 |
+
target_dtype = np.int16
|
9 |
+
max_range = np.iinfo(target_dtype).max
|
10 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
11 |
|
12 |
# load speech translation checkpoint
|
|
|
41 |
data_16 = librosa.resample(data_array, orig_sr=samplerate, target_sr=sampling_rate)
|
42 |
translated_text = translate(data_16)
|
43 |
synthesised_speech = synthesise(translated_text)
|
44 |
+
synthesised_speech = (synthesised_speech.numpy() * max_range).astype(np.int16)
|
45 |
+
return sampling_rate, synthesised_speech
|
46 |
|
47 |
|
48 |
title = "Cascaded STST"
|