Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,7 @@ def update_model(model_name):
|
|
44 |
|
45 |
|
46 |
|
47 |
-
def text_to_speech(text, model_name="kokoro-v0_19-half.pth", voice_name="af", speed=1.0, trim=
|
48 |
"""
|
49 |
Converts text to speech using the specified parameters and ensures the model is updated only if necessary.
|
50 |
"""
|
@@ -129,7 +129,6 @@ with gr.Blocks() as demo1:
|
|
129 |
# minimum=0, maximum=1, value=0, step=0.1,
|
130 |
# label='🔪 Trim', info='How much to cut from both ends of each segment'
|
131 |
# )
|
132 |
-
trim=0.5
|
133 |
pad_between = gr.Slider(
|
134 |
minimum=0, maximum=2, value=0, step=0.1,
|
135 |
label='🔇 Pad Between', info='Silent Duration between segments [For Large Text]'
|
@@ -143,12 +142,12 @@ with gr.Blocks() as demo1:
|
|
143 |
|
144 |
text.submit(
|
145 |
text_to_speech,
|
146 |
-
inputs=[text, model_name,voice, speed,
|
147 |
outputs=[audio]
|
148 |
)
|
149 |
generate_btn.click(
|
150 |
text_to_speech,
|
151 |
-
inputs=[text,model_name, voice, speed,
|
152 |
outputs=[audio]
|
153 |
)
|
154 |
|
@@ -258,7 +257,7 @@ import time
|
|
258 |
def your_tts(text,audio_path,actual_duration,speed=1.0):
|
259 |
global srt_voice_name
|
260 |
model_name="kokoro-v0_19.pth"
|
261 |
-
tts_path=text_to_speech(text, model_name, voice_name=srt_voice_name,speed=speed)
|
262 |
print(tts_path)
|
263 |
tts_audio = AudioSegment.from_file(tts_path)
|
264 |
tts_duration = len(tts_audio)
|
|
|
44 |
|
45 |
|
46 |
|
47 |
+
def text_to_speech(text, model_name="kokoro-v0_19-half.pth", voice_name="af", speed=1.0, trim=0.5, pad_between_segments=0, remove_silence=True, minimum_silence=0.20):
|
48 |
"""
|
49 |
Converts text to speech using the specified parameters and ensures the model is updated only if necessary.
|
50 |
"""
|
|
|
129 |
# minimum=0, maximum=1, value=0, step=0.1,
|
130 |
# label='🔪 Trim', info='How much to cut from both ends of each segment'
|
131 |
# )
|
|
|
132 |
pad_between = gr.Slider(
|
133 |
minimum=0, maximum=2, value=0, step=0.1,
|
134 |
label='🔇 Pad Between', info='Silent Duration between segments [For Large Text]'
|
|
|
142 |
|
143 |
text.submit(
|
144 |
text_to_speech,
|
145 |
+
inputs=[text, model_name,voice, speed, pad_between, remove_silence, minimum_silence],
|
146 |
outputs=[audio]
|
147 |
)
|
148 |
generate_btn.click(
|
149 |
text_to_speech,
|
150 |
+
inputs=[text,model_name, voice, speed, pad_between, remove_silence, minimum_silence],
|
151 |
outputs=[audio]
|
152 |
)
|
153 |
|
|
|
257 |
def your_tts(text,audio_path,actual_duration,speed=1.0):
|
258 |
global srt_voice_name
|
259 |
model_name="kokoro-v0_19.pth"
|
260 |
+
tts_path=text_to_speech(text, model_name, voice_name=srt_voice_name,speed=speed,trim=1.0)
|
261 |
print(tts_path)
|
262 |
tts_audio = AudioSegment.from_file(tts_path)
|
263 |
tts_duration = len(tts_audio)
|