Skip to content

Commit ddd0d45

Browse files
authored
bugfix: Set default sample rate (#107)
1 parent 5f83917 commit ddd0d45

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

demo/app.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def gen_button_clicked():
5656
st.session_state[gen_button] = True
5757

5858

59+
sample_rate = 24000
5960
st.title("Document To Podcast")
6061

6162
st.header("Upload a File")
@@ -166,6 +167,7 @@ def gen_button_clicked():
166167
# Get which language is used for generation from the first character of the Kokoro voice profile
167168
language_code = speakers[0]["voice_profile"][0]
168169
speech_model = load_text_to_speech_model(lang_code=language_code)
170+
sample_rate = speech_model.sample_rate
169171

170172
system_prompt = DEFAULT_PROMPT.replace("{SPEAKERS}", speakers_str)
171173
with st.spinner("Generating Podcast..."):
@@ -190,17 +192,17 @@ def gen_button_clicked():
190192
speech_model,
191193
voice_profile,
192194
)
193-
st.audio(speech, sample_rate=speech_model.sample_rate)
195+
st.audio(speech, sample_rate=sample_rate)
194196

195197
st.session_state.audio.append(speech)
196198
text = ""
197199
st.session_state.script += "}"
198200

199201
if st.session_state[gen_button]:
200202
audio_np = stack_audio_segments(
201-
st.session_state.audio, speech_model.sample_rate, silence_pad=0.0
203+
st.session_state.audio, sample_rate, silence_pad=0.0
202204
)
203-
audio_wav = numpy_to_wav(audio_np, speech_model.sample_rate)
205+
audio_wav = numpy_to_wav(audio_np, sample_rate)
204206
if st.download_button(
205207
label="Save Podcast to audio file",
206208
data=audio_wav,

0 commit comments

Comments
 (0)