fabiolamp commited on
Commit
5fed0a8
·
verified ·
1 Parent(s): ba1acac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -5,6 +5,7 @@ import os
5
  from PIL import Image
6
  import ffmpeg
7
  from pydub import AudioSegment
 
8
 
9
  import numpy as np
10
  import soundfile as sf
@@ -39,7 +40,13 @@ def run_infrence(input_image,input_audio):
39
  pil_image.save(filename)
40
 
41
  #Save input audio
42
- save_audio_mp3(input_audio, "sample_data/uploaded_audio.mp3")
 
 
 
 
 
 
43
 
44
  command = f'python3 inference.py --checkpoint_path checkpoints/wav2lip_gan.pth --face sample_data/uploaded_image.png --audio sample_data/uploaded_audio.mp3'
45
  process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
@@ -53,8 +60,9 @@ def run():
53
  with gr.Group():
54
  with gr.Row():
55
  input_image = gr.Image(label="Input Image")
56
- input_audio = gr.Audio(label="Input Audio")
57
- video_out = gr.Video(show_label=True,label="Output")
 
58
  with gr.Row():
59
  btn = gr.Button("Generate")
60
 
 
5
  from PIL import Image
6
  import ffmpeg
7
  from pydub import AudioSegment
8
+ from gtts import gTTS
9
 
10
  import numpy as np
11
  import soundfile as sf
 
40
  pil_image.save(filename)
41
 
42
  #Save input audio
43
+ #save_audio_mp3(input_audio, "sample_data/uploaded_audio.mp3")
44
+
45
+ if input_text:
46
+ tts = gTTS(input_text, lang='en', tld='com.au')
47
+ tts.save("sample_data/uploaded_audio.mp3")
48
+ else:
49
+ save_audio_mp3(input_audio, "sample_data/uploaded_audio.mp3")
50
 
51
  command = f'python3 inference.py --checkpoint_path checkpoints/wav2lip_gan.pth --face sample_data/uploaded_image.png --audio sample_data/uploaded_audio.mp3'
52
  process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
 
60
  with gr.Group():
61
  with gr.Row():
62
  input_image = gr.Image(label="Input Image")
63
+ input_audio = gr.Audio(label="Input Audio (Optional)")
64
+ input_text = gr.Textbox(label="Input Text (Optional)", placeholder="Enter text to convert to audio")
65
+ video_out = gr.Video(show_label=True, label="Output")
66
  with gr.Row():
67
  btn = gr.Button("Generate")
68