Spaces:
Build error
Build error
update global transcript text
Browse files
app.py
CHANGED
|
@@ -169,8 +169,8 @@ def format_timestamp(seconds: float, always_include_hours: bool = False, decimal
|
|
| 169 |
return seconds
|
| 170 |
|
| 171 |
|
| 172 |
-
def transcribe(file,
|
| 173 |
-
outputs = pipe(file, batch_size=BATCH_SIZE, generate_kwargs={"task":
|
| 174 |
text = outputs["text"]
|
| 175 |
if return_timestamps:
|
| 176 |
timestamps = outputs["chunks"]
|
|
@@ -197,7 +197,7 @@ mic_transcribe = gr.Interface(
|
|
| 197 |
fn=transcribe,
|
| 198 |
inputs=[
|
| 199 |
gr.inputs.Audio(source="microphone", type="filepath", optional=True),
|
| 200 |
-
|
| 201 |
gr.inputs.Checkbox(default=False, label="Return timestamps"),
|
| 202 |
],
|
| 203 |
outputs="text",
|
|
@@ -215,7 +215,7 @@ file_transcribe = gr.Interface(
|
|
| 215 |
fn=transcribe,
|
| 216 |
inputs=[
|
| 217 |
gr.inputs.Audio(source="upload", optional=True, label="Audio file", type="filepath"),
|
| 218 |
-
|
| 219 |
gr.inputs.Checkbox(default=False, label="Return timestamps"),
|
| 220 |
],
|
| 221 |
outputs="text",
|
|
@@ -273,6 +273,7 @@ def writenotes( LLMmodel,apikeystr,inputscript):
|
|
| 273 |
#text=transcribe_text
|
| 274 |
#openaikey.set_key(inputkey)
|
| 275 |
#openaikey = OpenAIKeyClass(inputkey)
|
|
|
|
| 276 |
print('ok')
|
| 277 |
if len(inputscript)>10: #有資料表示不是來自語音辨識結果
|
| 278 |
transcribe_text=inputscript
|
|
|
|
| 169 |
return seconds
|
| 170 |
|
| 171 |
|
| 172 |
+
def transcribe(file, return_timestamps):
|
| 173 |
+
outputs = pipe(file, batch_size=BATCH_SIZE, generate_kwargs={"task": "transcribe","language": "chinese",}, return_timestamps=return_timestamps)
|
| 174 |
text = outputs["text"]
|
| 175 |
if return_timestamps:
|
| 176 |
timestamps = outputs["chunks"]
|
|
|
|
| 197 |
fn=transcribe,
|
| 198 |
inputs=[
|
| 199 |
gr.inputs.Audio(source="microphone", type="filepath", optional=True),
|
| 200 |
+
# gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
|
| 201 |
gr.inputs.Checkbox(default=False, label="Return timestamps"),
|
| 202 |
],
|
| 203 |
outputs="text",
|
|
|
|
| 215 |
fn=transcribe,
|
| 216 |
inputs=[
|
| 217 |
gr.inputs.Audio(source="upload", optional=True, label="Audio file", type="filepath"),
|
| 218 |
+
# gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
|
| 219 |
gr.inputs.Checkbox(default=False, label="Return timestamps"),
|
| 220 |
],
|
| 221 |
outputs="text",
|
|
|
|
| 273 |
#text=transcribe_text
|
| 274 |
#openaikey.set_key(inputkey)
|
| 275 |
#openaikey = OpenAIKeyClass(inputkey)
|
| 276 |
+
global transcribe_text
|
| 277 |
print('ok')
|
| 278 |
if len(inputscript)>10: #有資料表示不是來自語音辨識結果
|
| 279 |
transcribe_text=inputscript
|