Spaces:
Running
Running
Commit
β’
6183a73
1
Parent(s):
51a692b
Upload 4 files
Browse files- ENG_US_F_ReddH.mp3 +0 -0
- ENG_US_M_PaulQ.mp3 +0 -0
- app (1).py +65 -0
- requirements (1).txt +3 -0
ENG_US_F_ReddH.mp3
ADDED
Binary file (355 kB). View file
|
|
ENG_US_M_PaulQ.mp3
ADDED
Binary file (298 kB). View file
|
|
app (1).py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
import requests
|
4 |
+
import io
|
5 |
+
from PIL import Image
|
6 |
+
from IPython.display import Audio, display
|
7 |
+
from freeGPT import Client
|
8 |
+
from gradio_client import Client
|
9 |
+
|
10 |
+
api_token = os.environ.get("API_TOKEN")
|
11 |
+
API_URL = "https://api-inference.huggingface.co/models/facebook/musicgen-small"
|
12 |
+
API_URL_IMG = "https://api-inference.huggingface.co/models/Salesforce/blip-image-captioning-large"
|
13 |
+
headers = {"Authorization": f"Bearer {api_token}"}
|
14 |
+
|
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
|
26 |
+
|
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.sidebar.title("β¨ Your AI Girl π")
|
39 |
+
st.sidebar.write("We will make a perfect talking girlfriend for you, just upload photo")
|
40 |
+
img_prompt = st.sidebar.file_uploader("Upload Image of your girl", type=["jpeg", "jpg", "png"])
|
41 |
+
gender = st.sidebar.selectbox(
|
42 |
+
'What will be your partner gender?',
|
43 |
+
('Female', 'Male')
|
44 |
+
)
|
45 |
+
sumbit_btn = st.sidebar.button("β¨ Create partner")
|
46 |
+
voice = None
|
47 |
+
female_voice = "female.mp3"
|
48 |
+
male_voice = "male.mp3"
|
49 |
+
if gender == 'Female':
|
50 |
+
voice = female_voice
|
51 |
+
else:
|
52 |
+
voice = male_voice
|
53 |
+
|
54 |
+
if sumbit_btn:
|
55 |
+
messages = st.container(height=300)
|
56 |
+
input_user = st.chat_input(placeholder='Enter message for your partner...')
|
57 |
+
answer = Client.create_completion("gpt3", f"Answer on this question as beautiful nice kind {gender}: " + input_user)
|
58 |
+
|
59 |
+
if input_user:
|
60 |
+
output_audio = get_speech(input_user, answer)
|
61 |
+
output_video = get_dreamtalk(img_prompt, output_audio)
|
62 |
+
with messages.message("user"):
|
63 |
+
st.write(input_user)
|
64 |
+
with messages.message("Partner", avatar=img_prompt):
|
65 |
+
st.video(output_video)
|
requirements (1).txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
freeGPT
|
2 |
+
ipython
|
3 |
+
gradio_client
|