Spaces:
Running
Running
SnJForever
commited on
Commit
•
8d53ec5
1
Parent(s):
b224880
update video bot
Browse files- app.py +8 -8
- videos/Masahiro.mp4 +0 -3
- videos/Michelle.mp4 +0 -0
- videos/tempfile.mp4 +0 -0
app.py
CHANGED
@@ -53,7 +53,7 @@ BUG_FOUND_MSG = "Congratulations, you've found a bug in this application!"
|
|
53 |
AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. "
|
54 |
MAX_TOKENS = 512
|
55 |
|
56 |
-
LOOPING_TALKING_HEAD = "videos/
|
57 |
TALKING_HEAD_WIDTH = "192"
|
58 |
MAX_TALKING_HEAD_TEXT_LENGTH = 155
|
59 |
|
@@ -506,7 +506,7 @@ def do_html_audio_speak(words_to_speak, polly_language):
|
|
506 |
|
507 |
def create_html_video(file_name, width):
|
508 |
temp_file_url = "/file=" + tmp_file.value['name']
|
509 |
-
html_video = f'<video width={width} height={width} autoplay muted loop><source src={temp_file_url} type="video/mp4" poster="
|
510 |
return html_video
|
511 |
|
512 |
|
@@ -517,7 +517,7 @@ def do_html_video_speak(words_to_speak, azure_language):
|
|
517 |
|
518 |
headers = {"Authorization": f"Bearer {os.environ['EXHUMAN_API_KEY']}"}
|
519 |
body = {
|
520 |
-
'bot_name': '
|
521 |
'bot_response': words_to_speak,
|
522 |
'azure_voice': azure_voice,
|
523 |
'azure_style': 'friendly',
|
@@ -536,7 +536,7 @@ def do_html_video_speak(words_to_speak, azure_language):
|
|
536 |
f.write(response_stream.read())
|
537 |
temp_file = gr.File("videos/tempfile.mp4")
|
538 |
temp_file_url = "/file=" + temp_file.value['name']
|
539 |
-
html_video = f'<video width={TALKING_HEAD_WIDTH} height={TALKING_HEAD_WIDTH} autoplay><source src={temp_file_url} type="video/mp4" poster="
|
540 |
else:
|
541 |
print('video url unknown')
|
542 |
return html_video, "videos/tempfile.mp4"
|
@@ -640,11 +640,11 @@ with gr.Blocks(css=".gradio-container {background-color: lightgray}") as block:
|
|
640 |
# speak_text_cb.change(update_foo, inputs=[speak_text_cb, speak_text_state],
|
641 |
# outputs=[speak_text_state])
|
642 |
|
643 |
-
|
644 |
-
|
645 |
# tmp_file_url = "/file=" + tmp_file.value['name']
|
646 |
-
|
647 |
-
|
648 |
|
649 |
# my_aud_file = gr.File(label="Audio file", type="file", visible=True)
|
650 |
tmp_aud_file = gr.File("audios/tempfile.mp3", visible=False)
|
|
|
53 |
AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. "
|
54 |
MAX_TOKENS = 512
|
55 |
|
56 |
+
LOOPING_TALKING_HEAD = "videos/Michelle.mp4"
|
57 |
TALKING_HEAD_WIDTH = "192"
|
58 |
MAX_TALKING_HEAD_TEXT_LENGTH = 155
|
59 |
|
|
|
506 |
|
507 |
def create_html_video(file_name, width):
|
508 |
temp_file_url = "/file=" + tmp_file.value['name']
|
509 |
+
html_video = f'<video width={width} height={width} autoplay muted loop><source src={temp_file_url} type="video/mp4" poster="Michelle.png"></video>'
|
510 |
return html_video
|
511 |
|
512 |
|
|
|
517 |
|
518 |
headers = {"Authorization": f"Bearer {os.environ['EXHUMAN_API_KEY']}"}
|
519 |
body = {
|
520 |
+
'bot_name': 'Michelle',
|
521 |
'bot_response': words_to_speak,
|
522 |
'azure_voice': azure_voice,
|
523 |
'azure_style': 'friendly',
|
|
|
536 |
f.write(response_stream.read())
|
537 |
temp_file = gr.File("videos/tempfile.mp4")
|
538 |
temp_file_url = "/file=" + temp_file.value['name']
|
539 |
+
html_video = f'<video width={TALKING_HEAD_WIDTH} height={TALKING_HEAD_WIDTH} autoplay><source src={temp_file_url} type="video/mp4" poster="Michelle.png"></video>'
|
540 |
else:
|
541 |
print('video url unknown')
|
542 |
return html_video, "videos/tempfile.mp4"
|
|
|
640 |
# speak_text_cb.change(update_foo, inputs=[speak_text_cb, speak_text_state],
|
641 |
# outputs=[speak_text_state])
|
642 |
|
643 |
+
my_file = gr.File(label="Upload a file", type="file", visible=False)
|
644 |
+
tmp_file = gr.File(LOOPING_TALKING_HEAD, visible=False)
|
645 |
# tmp_file_url = "/file=" + tmp_file.value['name']
|
646 |
+
htm_video = create_html_video(LOOPING_TALKING_HEAD, TALKING_HEAD_WIDTH)
|
647 |
+
video_html = gr.HTML(htm_video)
|
648 |
|
649 |
# my_aud_file = gr.File(label="Audio file", type="file", visible=True)
|
650 |
tmp_aud_file = gr.File("audios/tempfile.mp3", visible=False)
|
videos/Masahiro.mp4
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:ca886517414fae8bcea5a5130ae1d01ef3ead7aed437203abebf032217fd0be6
|
3 |
-
size 2425212
|
|
|
|
|
|
|
|
videos/Michelle.mp4
ADDED
Binary file (172 kB). View file
|
|
videos/tempfile.mp4
CHANGED
Binary files a/videos/tempfile.mp4 and b/videos/tempfile.mp4 differ
|
|