naveenk-ai commited on
Commit
f33af1e
·
verified ·
1 Parent(s): 918c36e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -167,7 +167,25 @@ reference_speakers = [
167
  "record_manually",
168
  "load_manually",
169
  ]
170
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  def save_audio(voice_source: widgets.FileUpload, out_path: str):
172
  with open(out_path, "wb") as output_file:
173
  assert len(voice_source.value) > 0, "Please select audio file"
 
167
  "record_manually",
168
  "load_manually",
169
  ]
170
+ ref_speaker_path = f"{REFERENCE_VOICES_PATH}/{ref_speaker.value}"
171
+ allowed_audio_types = ".mp4,.mp3,.wav,.wma,.aac,.m4a,.m4b,.webm"
172
+
173
+ if ref_speaker.value == "record_manually":
174
+ ref_speaker_path = f"{OUTPUT_DIR}/custom_example_sample.webm"
175
+ from ipywebrtc import AudioRecorder, CameraStream
176
+
177
+ camera = CameraStream(constraints={"audio": True, "video": False})
178
+ recorder = AudioRecorder(stream=camera, filename=ref_speaker_path, autosave=True)
179
+ display(recorder)
180
+
181
+ elif ref_speaker.value == "load_manually":
182
+ upload_ref = widgets.FileUpload(
183
+ accept=allowed_audio_types,
184
+ multiple=False,
185
+ description="Select audio with reference voice",
186
+ )
187
+ display(upload_ref)
188
+
189
  def save_audio(voice_source: widgets.FileUpload, out_path: str):
190
  with open(out_path, "wb") as output_file:
191
  assert len(voice_source.value) > 0, "Please select audio file"