kevinwang676 commited on
Commit
d91523b
1 Parent(s): d0f4435

Update app_multi.py

Browse files
Files changed (1) hide show
  1. app_multi.py +16 -2
app_multi.py CHANGED
@@ -12,6 +12,7 @@ import asyncio
12
  import json
13
  import hashlib
14
  from os import path, getenv
 
15
 
16
  import gradio as gr
17
 
@@ -137,6 +138,16 @@ print(f'Models loaded: {len(loaded_models)}')
137
  # Edge TTS speakers
138
  tts_speakers_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices()) # noqa
139
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  # Bilibili
142
  def youtube_downloader(
@@ -436,8 +447,9 @@ with app:
436
  with gr.Column():
437
  with gr.Tab('Audio conversion'):
438
  input_audio = as_audio_vocals
439
-
440
- vc_convert_btn = gr.Button('Convert', variant='primary')
 
441
 
442
  with gr.Tab('TTS conversion'):
443
  tts_input = gr.TextArea(
@@ -587,6 +599,8 @@ with app:
587
  api_name='tts_conversion'
588
  )
589
 
 
 
590
  model_index.change(
591
  update_model_info,
592
  inputs=[model_index],
 
12
  import json
13
  import hashlib
14
  from os import path, getenv
15
+ from pydub import AudioSegment
16
 
17
  import gradio as gr
18
 
 
138
  # Edge TTS speakers
139
  tts_speakers_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices()) # noqa
140
 
141
+ # mix vocal and non-vocal
142
+ def mix(audio1, audio2):
143
+ sound1 = AudioSegment.from_file(audio1)
144
+ sound2 = AudioSegment.from_file(audio2)
145
+ length = len(sound1)
146
+ mixed = sound1[:length].overlay(sound2)
147
+
148
+ mixed.export("song.wav", format="wav")
149
+
150
+ return "song.wav"
151
 
152
  # Bilibili
153
  def youtube_downloader(
 
447
  with gr.Column():
448
  with gr.Tab('Audio conversion'):
449
  input_audio = as_audio_vocals
450
+ vc_convert_btn = gr.Button('进行歌声转换吧!', variant='primary')
451
+ full_song = gr.Button("加入歌曲伴奏吧!", variant="primary")
452
+ new_song = gr.Audio(label="Full song", type="filepath")
453
 
454
  with gr.Tab('TTS conversion'):
455
  tts_input = gr.TextArea(
 
599
  api_name='tts_conversion'
600
  )
601
 
602
+ full_song.click(fn=mix, inputs=[output_audio, as_audio_no_vocals], outputs=[new_song])
603
+
604
  model_index.change(
605
  update_model_info,
606
  inputs=[model_index],