Spaces:
Sleeping
Sleeping
bofenghuang
commited on
Commit
·
2263e75
1
Parent(s):
21b463c
up
Browse files- app.py +1 -1
- run_demo_openai_merged.py +6 -6
app.py
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
|
|
1 |
+
run_demo_openai_merged.py
|
run_demo_openai_merged.py
CHANGED
@@ -46,7 +46,7 @@ cached_models = {}
|
|
46 |
def _print_memory_info():
|
47 |
memory = psutil.virtual_memory()
|
48 |
logger.info(
|
49 |
-
f"Memory: {memory.
|
50 |
)
|
51 |
|
52 |
|
@@ -99,7 +99,7 @@ def download_from_youtube(yt_url, downloaded_filename="audio.wav"):
|
|
99 |
|
100 |
def transcribe(microphone, file_upload, yt_url, with_timestamps, model_name=DEFAULT_MODEL_NAME):
|
101 |
warn_output = ""
|
102 |
-
if (microphone is not None) and (file_upload is not None) and
|
103 |
warn_output = (
|
104 |
"WARNING: You've uploaded an audio file, used the microphone, and pasted a YouTube URL. "
|
105 |
"The recorded file from the microphone will be used, the uploaded audio and the YouTube URL will be discarded.\n"
|
@@ -111,19 +111,19 @@ def transcribe(microphone, file_upload, yt_url, with_timestamps, model_name=DEFA
|
|
111 |
"The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
|
112 |
)
|
113 |
|
114 |
-
if (microphone is not None) and
|
115 |
warn_output = (
|
116 |
"WARNING: You've used the microphone and pasted a YouTube URL. "
|
117 |
"The recorded file from the microphone will be used and the YouTube URL will be discarded.\n"
|
118 |
)
|
119 |
|
120 |
-
if (file_upload is not None) and
|
121 |
warn_output = (
|
122 |
"WARNING: You've uploaded an audio file and pasted a YouTube URL. "
|
123 |
"The uploaded audio will be used and the YouTube URL will be discarded.\n"
|
124 |
)
|
125 |
|
126 |
-
elif (microphone is None) and (file_upload is None) and (yt_url
|
127 |
return "ERROR: You have to either use the microphone, upload an audio file or paste a YouTube URL"
|
128 |
|
129 |
if microphone is not None:
|
@@ -154,7 +154,7 @@ demo = gr.Interface(
|
|
154 |
gr.inputs.Audio(source="microphone", type="filepath", label="Record", optional=True),
|
155 |
gr.inputs.Audio(source="upload", type="filepath", label="Upload File", optional=True),
|
156 |
gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL", optional=True),
|
157 |
-
gr.Checkbox(label="With timestamps?"
|
158 |
],
|
159 |
# outputs="text",
|
160 |
outputs=gr.outputs.Textbox(label="Transcription"),
|
|
|
46 |
def _print_memory_info():
|
47 |
memory = psutil.virtual_memory()
|
48 |
logger.info(
|
49 |
+
f"Memory info - Free: {memory.available / (1024 ** 3):.2f} Gb, used: {memory.percent}%, total: {memory.total / (1024 ** 3):.2f} Gb"
|
50 |
)
|
51 |
|
52 |
|
|
|
99 |
|
100 |
def transcribe(microphone, file_upload, yt_url, with_timestamps, model_name=DEFAULT_MODEL_NAME):
|
101 |
warn_output = ""
|
102 |
+
if (microphone is not None) and (file_upload is not None) and yt_url:
|
103 |
warn_output = (
|
104 |
"WARNING: You've uploaded an audio file, used the microphone, and pasted a YouTube URL. "
|
105 |
"The recorded file from the microphone will be used, the uploaded audio and the YouTube URL will be discarded.\n"
|
|
|
111 |
"The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
|
112 |
)
|
113 |
|
114 |
+
if (microphone is not None) and yt_url:
|
115 |
warn_output = (
|
116 |
"WARNING: You've used the microphone and pasted a YouTube URL. "
|
117 |
"The recorded file from the microphone will be used and the YouTube URL will be discarded.\n"
|
118 |
)
|
119 |
|
120 |
+
if (file_upload is not None) and yt_url:
|
121 |
warn_output = (
|
122 |
"WARNING: You've uploaded an audio file and pasted a YouTube URL. "
|
123 |
"The uploaded audio will be used and the YouTube URL will be discarded.\n"
|
124 |
)
|
125 |
|
126 |
+
elif (microphone is None) and (file_upload is None) and (not yt_url):
|
127 |
return "ERROR: You have to either use the microphone, upload an audio file or paste a YouTube URL"
|
128 |
|
129 |
if microphone is not None:
|
|
|
154 |
gr.inputs.Audio(source="microphone", type="filepath", label="Record", optional=True),
|
155 |
gr.inputs.Audio(source="upload", type="filepath", label="Upload File", optional=True),
|
156 |
gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL", optional=True),
|
157 |
+
gr.Checkbox(label="With timestamps?"),
|
158 |
],
|
159 |
# outputs="text",
|
160 |
outputs=gr.outputs.Textbox(label="Transcription"),
|