fffiloni commited on
Commit
9166220
·
1 Parent(s): 8562ba3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  #import requests
 
3
  from PIL import Image
4
  import os
5
  token = os.environ.get('HF_TOKEN')
@@ -7,16 +8,33 @@ whisper_to_gpt = gr.Blocks.load(name="spaces/fffiloni/whisper-to-chatGPT")
7
  tts = gr.Interface.load(name="spaces/Flux9665/IMS-Toucan")
8
  talking_face = gr.Blocks.load(name="spaces/fffiloni/one-shot-talking-face", api_key=token)
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  def infer(audio):
11
  gpt_response = whisper_to_gpt(audio, "translate", fn_index=0)
12
  #print(gpt_response)
13
  audio_response = tts(gpt_response[1], "English Text", "English Accent", "English Speaker's Voice", fn_index=0)
14
  #image = Image.open(r"wise_woman_portrait.png")
15
  portrait_link = talking_face("wise_woman_portrait.png", audio_response, fn_index=0)
16
-
 
17
  #portrait_response = requests.get(portrait_link, headers={'Authorization': 'Bearer ' + token})
18
  #print(portrait_response.text)
19
- return portrait_link
20
 
21
  title = """
22
  <div style="text-align: center; max-width: 500px; margin: 0 auto;">
 
1
  import gradio as gr
2
  #import requests
3
+ from moviepy.editor import VideoFileClip
4
  from PIL import Image
5
  import os
6
  token = os.environ.get('HF_TOKEN')
 
8
  tts = gr.Interface.load(name="spaces/Flux9665/IMS-Toucan")
9
  talking_face = gr.Blocks.load(name="spaces/fffiloni/one-shot-talking-face", api_key=token)
10
 
11
+ def apply_delay(video_path):
12
+
13
+ # Open the video file
14
+ video = VideoFileClip(video_path)
15
+
16
+ # Delay the audio by 1 ms
17
+ delayed_audio = video.audio.fx(afx.delay, 0.5)
18
+
19
+ # Overwrite the original audio with the delayed audio
20
+ video = video.set_audio(delayed_audio)
21
+
22
+ # Save the modified video
23
+ video.write_videofile("delayed_video.mp4")
24
+
25
+ return "delayed_video.mp4"
26
+
27
  def infer(audio):
28
  gpt_response = whisper_to_gpt(audio, "translate", fn_index=0)
29
  #print(gpt_response)
30
  audio_response = tts(gpt_response[1], "English Text", "English Accent", "English Speaker's Voice", fn_index=0)
31
  #image = Image.open(r"wise_woman_portrait.png")
32
  portrait_link = talking_face("wise_woman_portrait.png", audio_response, fn_index=0)
33
+
34
+ final_vid = apply_delay(portrait_link)
35
  #portrait_response = requests.get(portrait_link, headers={'Authorization': 'Bearer ' + token})
36
  #print(portrait_response.text)
37
+ return final_vid
38
 
39
  title = """
40
  <div style="text-align: center; max-width: 500px; margin: 0 auto;">