Spaces:
Running
Running
Commit
•
fbf2802
1
Parent(s):
e0ec723
Update app.py
Browse files
app.py
CHANGED
@@ -15,11 +15,11 @@ from gradio_client import Client
|
|
15 |
def get_speech(text, voice):
|
16 |
client = Client("https://collabora-whisperspeech.hf.space/")
|
17 |
result = client.predict(
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
)
|
24 |
print(result)
|
25 |
return result
|
@@ -27,15 +27,15 @@ def get_speech(text, voice):
|
|
27 |
def get_dreamtalk(image_in, speech):
|
28 |
client = Client("https://fffiloni-dreamtalk.hf.space/")
|
29 |
result = client.predict(
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
)
|
35 |
print(result)
|
36 |
return result['video']
|
37 |
|
38 |
-
st.title("✨️ AI
|
39 |
st.header("To create partner use sidebar (tap on ▶️ button on the left top)", divider="rainbow")
|
40 |
st.sidebar.title("✨ Your AI Girl 🔞")
|
41 |
st.sidebar.write("We will make a perfect talking girlfriend for you, just upload photo")
|
@@ -52,21 +52,21 @@ if gender == 'Female':
|
|
52 |
voice = female_voice
|
53 |
else:
|
54 |
voice = male_voice
|
55 |
-
|
56 |
-
messages = None
|
57 |
if sumbit_btn:
|
58 |
messages = st.container(height=300)
|
59 |
input_user = st.chat_input(placeholder='Enter message for your partner...')
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
15 |
def get_speech(text, voice):
|
16 |
client = Client("https://collabora-whisperspeech.hf.space/")
|
17 |
result = client.predict(
|
18 |
+
text, # str in 'Enter multilingual text💬📝' Textbox component
|
19 |
+
voice, # filepath in 'Upload or Record Speaker Audio (optional)🌬️💬' Audio component
|
20 |
+
"", # str in 'alternatively, you can paste in an audio file URL:' Textbox component
|
21 |
+
14, # float (numeric value between 10 and 15) in 'Tempo (in characters per second)' Slider component
|
22 |
+
api_name="/whisper_speech_demo"
|
23 |
)
|
24 |
print(result)
|
25 |
return result
|
|
|
27 |
def get_dreamtalk(image_in, speech):
|
28 |
client = Client("https://fffiloni-dreamtalk.hf.space/")
|
29 |
result = client.predict(
|
30 |
+
speech, # filepath in 'Audio input' Audio component
|
31 |
+
image_in, # filepath in 'Image' Image component
|
32 |
+
"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
|
33 |
+
api_name="/infer"
|
34 |
)
|
35 |
print(result)
|
36 |
return result['video']
|
37 |
|
38 |
+
st.title("✨️ AI Partner")
|
39 |
st.header("To create partner use sidebar (tap on ▶️ button on the left top)", divider="rainbow")
|
40 |
st.sidebar.title("✨ Your AI Girl 🔞")
|
41 |
st.sidebar.write("We will make a perfect talking girlfriend for you, just upload photo")
|
|
|
52 |
voice = female_voice
|
53 |
else:
|
54 |
voice = male_voice
|
55 |
+
|
|
|
56 |
if sumbit_btn:
|
57 |
messages = st.container(height=300)
|
58 |
input_user = st.chat_input(placeholder='Enter message for your partner...')
|
59 |
+
messages = st.container(height=300)
|
60 |
+
|
61 |
+
if input_user:
|
62 |
+
answer = gptClient.create_completion("gpt3", f"Answer on this question as beautiful nice kind {gender}: " + input_user)
|
63 |
+
print("Answer generated. Generating audio")
|
64 |
+
output_audio = get_speech(input_user, answer)
|
65 |
+
print("Audio generated. Generating video")
|
66 |
+
output_video = get_dreamtalk(img_prompt, output_audio)
|
67 |
+
print("Video Generating. Sending to user")
|
68 |
|
69 |
+
with messages.message("user"):
|
70 |
+
st.write(input_user)
|
71 |
+
with messages.message("Partner", avatar=img_prompt):
|
72 |
+
st.video(output_video)
|