Spaces:
Runtime error
Runtime error
Manu
commited on
Commit
·
e8b9495
1
Parent(s):
1e645a6
added sentencepiece tokenizer and updated requirements.txt
Browse files- app.py +20 -5
- requirements.txt +1 -0
app.py
CHANGED
@@ -50,15 +50,30 @@ def synthesise_audio(text, forward_params=None):
|
|
50 |
# audio = f.getvalue()
|
51 |
|
52 |
# Convert numpy array to audio
|
53 |
-
audio = np.int16(speech["audio"] * 32767)
|
54 |
-
audio_segment = AudioSegment(audio, sample_width=2, frame_rate=speech["sampling_rate"], channels=1)
|
55 |
-
|
56 |
|
|
|
|
|
57 |
|
58 |
#return speech["audio"]
|
59 |
|
60 |
-
return audio
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
|
64 |
|
|
|
50 |
# audio = f.getvalue()
|
51 |
|
52 |
# Convert numpy array to audio
|
53 |
+
#audio = np.int16(speech["audio"] * 32767)
|
54 |
+
#audio_segment = AudioSegment(audio, sample_width=2, frame_rate=speech["sampling_rate"], channels=1)
|
|
|
55 |
|
56 |
+
# Convert numpy array to list
|
57 |
+
#audio = speech["audio"]
|
58 |
|
59 |
#return speech["audio"]
|
60 |
|
61 |
+
#return audio
|
62 |
+
|
63 |
+
|
64 |
+
# Create an in-memory buffer to store the audio data
|
65 |
+
audio_buffer = io.BytesIO()
|
66 |
+
|
67 |
+
# Write the audio data to the in-memory buffer
|
68 |
+
sf.write(audio_buffer, speech["audio"], samplerate=speech["sampling_rate"], format="WAV")
|
69 |
+
|
70 |
+
# Move the buffer cursor to the beginning of the buffer
|
71 |
+
audio_buffer.seek(0)
|
72 |
+
|
73 |
+
# Read the audio data from the in-memory buffer into a numpy array
|
74 |
+
audio, sr = sf.read(audio_buffer)
|
75 |
+
|
76 |
+
return audio, sr
|
77 |
|
78 |
|
79 |
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
transformers
|
2 |
soundfile
|
3 |
torch
|
|
|
|
1 |
transformers
|
2 |
soundfile
|
3 |
torch
|
4 |
+
sentencepiece
|