Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -102,7 +102,7 @@ recognizer = speech_recognition.Recognizer()
|
|
102 |
vg = VoiceGenerator()
|
103 |
|
104 |
|
105 |
-
def get_video(pathToWav, pathToImage):
|
106 |
files = [
|
107 |
("input_face", open(pathToImage, "rb")),
|
108 |
("input_audio", open(pathToWav, "rb")),
|
@@ -117,6 +117,9 @@ def get_video(pathToWav, pathToImage):
|
|
117 |
data={"json": json.dumps(payload)}
|
118 |
)
|
119 |
assert response.ok, response.content
|
|
|
|
|
|
|
120 |
|
121 |
|
122 |
def result(audio):
|
@@ -128,15 +131,18 @@ def result(audio):
|
|
128 |
write(file_path, sample_rate, data)
|
129 |
text_from_audio = recognize_audio(file_path)
|
130 |
generated_audio = vg.generate(ask_gpt(text_from_audio))
|
131 |
-
referenceName = ''
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
134 |
|
135 |
|
136 |
demo = gr.Interface(
|
137 |
result,
|
138 |
gr.Audio(sources=["microphone"]),
|
139 |
-
"
|
140 |
)
|
141 |
|
142 |
demo.launch()
|
|
|
102 |
vg = VoiceGenerator()
|
103 |
|
104 |
|
105 |
+
def get_video(pathToWav, pathToImage, pathToResult):
|
106 |
files = [
|
107 |
("input_face", open(pathToImage, "rb")),
|
108 |
("input_audio", open(pathToWav, "rb")),
|
|
|
117 |
data={"json": json.dumps(payload)}
|
118 |
)
|
119 |
assert response.ok, response.content
|
120 |
+
result = response.json()
|
121 |
+
#print(response.status_code, result["output"]["output_video"])
|
122 |
+
urllib.request.urlretrieve(result["output"]["output_video"], pathToResult)
|
123 |
|
124 |
|
125 |
def result(audio):
|
|
|
131 |
write(file_path, sample_rate, data)
|
132 |
text_from_audio = recognize_audio(file_path)
|
133 |
generated_audio = vg.generate(ask_gpt(text_from_audio))
|
134 |
+
referenceName = 'reference.jpg'
|
135 |
+
resultName = 'video.mp4'
|
136 |
+
pathToReference = os.path.join(PATH_TO_OUTPUT, referenceName)
|
137 |
+
pathToResult = os.path.join(PATH_TO_OUTPUT, resultName)
|
138 |
+
get_video(generated_audio, pathToReference, pathToResult)
|
139 |
+
return pathToResult
|
140 |
|
141 |
|
142 |
demo = gr.Interface(
|
143 |
result,
|
144 |
gr.Audio(sources=["microphone"]),
|
145 |
+
"playable_video", #playable_video
|
146 |
)
|
147 |
|
148 |
demo.launch()
|