fffiloni commited on
Commit
7572555
1 Parent(s): f81a8ad

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gradio_client import Client
3
+
4
+ def get_speech(text, voice):
5
+ client = Client("https://collabora-whisperspeech.hf.space/")
6
+ result = client.predict(
7
+ text, # str in 'Enter multilingual text💬📝' Textbox component
8
+ voice, # filepath in 'Upload or Record Speaker Audio (optional)🌬️💬' Audio component
9
+ "", # str in 'alternatively, you can paste in an audio file URL:' Textbox component
10
+ 14, # float (numeric value between 10 and 15) in 'Tempo (in characters per second)' Slider component
11
+ api_name="/whisper_speech_demo"
12
+ )
13
+ print(result)
14
+ return result
15
+
16
+ def get_dreamtalk(image_in, speech):
17
+ client = Client("https://fffiloni-dreamtalk.hf.space/")
18
+ result = client.predict(
19
+ speech, # filepath in 'Audio input' Audio component
20
+ image_in, # filepath in 'Image' Image component
21
+ "M030_front_neutral_level1_001.mat", # Literal['M030_front_angry_level3_001.mat', 'M030_front_contempt_level3_001.mat', 'M030_front_disgusted_level3_001.mat', 'M030_front_fear_level3_001.mat', 'M030_front_happy_level3_001.mat', 'M030_front_neutral_level1_001.mat', 'M030_front_sad_level3_001.mat', 'M030_front_surprised_level3_001.mat', 'W009_front_angry_level3_001.mat', 'W009_front_contempt_level3_001.mat', 'W009_front_disgusted_level3_001.mat', 'W009_front_fear_level3_001.mat', 'W009_front_happy_level3_001.mat', 'W009_front_neutral_level1_001.mat', 'W009_front_sad_level3_001.mat', 'W009_front_surprised_level3_001.mat', 'W011_front_angry_level3_001.mat', 'W011_front_contempt_level3_001.mat', 'W011_front_disgusted_level3_001.mat', 'W011_front_fear_level3_001.mat', 'W011_front_happy_level3_001.mat', 'W011_front_neutral_level1_001.mat', 'W011_front_sad_level3_001.mat', 'W011_front_surprised_level3_001.mat'] in 'emotional style' Dropdown component
22
+ api_name="/infer"
23
+ )
24
+ print(result)
25
+ return result['video']
26
+
27
+ def pipe (text, voice, image_in):
28
+
29
+ speech = get_speech(text, voice)
30
+ video = get_dreamtalk(image_in, speech)
31
+
32
+ return video
33
+
34
+ with gr.Blocks() as demo:
35
+ with gr.Column():
36
+ gr.HTML("""
37
+ """)
38
+ with gr.Row():
39
+ with gr.Column():
40
+ text = gr.Textbox(label="text")
41
+ voice = gr.Audio(type="filepath")
42
+ image_in = gr.Image(type="filepath")
43
+ submit_btn = gr.Button('Submit')
44
+ with gr.Column():
45
+ video_o = gr.Video()
46
+ submit_btn.click(
47
+ fn = pipe,
48
+ inputs = [
49
+ text, voice, image_in
50
+ ],
51
+ outputs = [
52
+ video_o
53
+ ]
54
+ )
55
+ demo.queue().launch(show_error=True)