Spaces:
Running
Running
Update generate_audio.py
Browse files- generate_audio.py +4 -3
generate_audio.py
CHANGED
|
@@ -19,7 +19,7 @@ class TTSGenerator:
|
|
| 19 |
A class to generate podcast-style audio from a transcript using ParlerTTS and Bark models.
|
| 20 |
"""
|
| 21 |
@spaces.GPU
|
| 22 |
-
def __init__(self, transcript_file_path):
|
| 23 |
"""
|
| 24 |
Initialize the TTS generator with the path to the rewritten transcript file.
|
| 25 |
|
|
@@ -27,7 +27,7 @@ class TTSGenerator:
|
|
| 27 |
transcript_file_path (str): Path to the file containing the rewritten transcript.
|
| 28 |
"""
|
| 29 |
self.transcript_file_path = transcript_file_path
|
| 30 |
-
self.output_audio_path =
|
| 31 |
|
| 32 |
# Set device
|
| 33 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -109,7 +109,8 @@ class TTSGenerator:
|
|
| 109 |
wavfile.write(byte_io, sampling_rate, audio_int16)
|
| 110 |
byte_io.seek(0)
|
| 111 |
return AudioSegment.from_wav(byte_io)
|
| 112 |
-
|
|
|
|
| 113 |
def generate_audio(self):
|
| 114 |
"""
|
| 115 |
Converts the transcript into audio and saves it to a file.
|
|
|
|
| 19 |
A class to generate podcast-style audio from a transcript using ParlerTTS and Bark models.
|
| 20 |
"""
|
| 21 |
@spaces.GPU
|
| 22 |
+
def __init__(self, transcript_file_path,output_audio_path):
|
| 23 |
"""
|
| 24 |
Initialize the TTS generator with the path to the rewritten transcript file.
|
| 25 |
|
|
|
|
| 27 |
transcript_file_path (str): Path to the file containing the rewritten transcript.
|
| 28 |
"""
|
| 29 |
self.transcript_file_path = transcript_file_path
|
| 30 |
+
self.output_audio_path = output_audio_path
|
| 31 |
|
| 32 |
# Set device
|
| 33 |
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 109 |
wavfile.write(byte_io, sampling_rate, audio_int16)
|
| 110 |
byte_io.seek(0)
|
| 111 |
return AudioSegment.from_wav(byte_io)
|
| 112 |
+
|
| 113 |
+
@spaces.GPU
|
| 114 |
def generate_audio(self):
|
| 115 |
"""
|
| 116 |
Converts the transcript into audio and saves it to a file.
|