Spaces:
Running
on
T4
Running
on
T4
knowsuchagency
commited on
Commit
•
fb76d6c
1
Parent(s):
5f34d90
add transcript to output
Browse files
main.py
CHANGED
@@ -88,19 +88,25 @@ def generate_audio(file: bytes, openai_api_key: str = None) -> bytes:
|
|
88 |
|
89 |
llm_output = generate_dialogue(text)
|
90 |
|
91 |
-
|
|
|
|
|
92 |
characters = 0
|
93 |
|
94 |
for line in llm_output.dialogue:
|
95 |
-
|
|
|
|
|
|
|
|
|
96 |
|
97 |
-
audio
|
98 |
-
result += audio
|
99 |
characters += len(line.text)
|
|
|
100 |
|
101 |
logger.info(f"Generated {characters} characters of audio")
|
102 |
|
103 |
-
return
|
104 |
|
105 |
|
106 |
demo = gr.Interface(
|
@@ -117,7 +123,8 @@ demo = gr.Interface(
|
|
117 |
),
|
118 |
],
|
119 |
outputs=[
|
120 |
-
gr.Audio(format="mp3"),
|
|
|
121 |
],
|
122 |
allow_flagging=False,
|
123 |
clear_btn=None,
|
|
|
88 |
|
89 |
llm_output = generate_dialogue(text)
|
90 |
|
91 |
+
audio = b""
|
92 |
+
transcript = ""
|
93 |
+
|
94 |
characters = 0
|
95 |
|
96 |
for line in llm_output.dialogue:
|
97 |
+
transcript_line = f"{line.speaker}: {line.text}"
|
98 |
+
|
99 |
+
logger.info(transcript_line)
|
100 |
+
|
101 |
+
audio_chunk = get_mp3(line.text, line.voice, openai_api_key)
|
102 |
|
103 |
+
audio += audio_chunk
|
|
|
104 |
characters += len(line.text)
|
105 |
+
transcript += transcript_line + "\n\n"
|
106 |
|
107 |
logger.info(f"Generated {characters} characters of audio")
|
108 |
|
109 |
+
return audio, transcript
|
110 |
|
111 |
|
112 |
demo = gr.Interface(
|
|
|
123 |
),
|
124 |
],
|
125 |
outputs=[
|
126 |
+
gr.Audio(label="Audio", format="mp3"),
|
127 |
+
gr.Textbox(label="Transcript"),
|
128 |
],
|
129 |
allow_flagging=False,
|
130 |
clear_btn=None,
|