jpdiazpardo commited on
Commit
77fc3c3
1 Parent(s): a9cc401

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -16,17 +16,20 @@ pipe = pipeline(
16
  )
17
 
18
  def transcribe(file, task, return_timestamps):
19
- outputs = pipe(file, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=return_timestamps)
20
  text = outputs["text"]
21
- if return_timestamps:
22
- timestamps = outputs["chunks"]
23
- timestamps = [
24
- f"[{format_timestamp(chunk['timestamp'][0])} -> {format_timestamp(chunk['timestamp'][1])}] {chunk['text']}"
25
- for chunk in timestamps
26
- ]
27
- text = "\n".join(str(feature) for feature in timestamps)
 
 
28
  return text
29
 
 
30
  file_transcribe = gr.Interface(
31
  fn=transcribe,
32
  inputs=[
@@ -48,4 +51,4 @@ file_transcribe = gr.Interface(
48
  allow_flagging="never",
49
  )
50
 
51
- file_transcribe.launch(enable_queue=True)
 
16
  )
17
 
18
  def transcribe(file, task, return_timestamps):
19
+ outputs = pipe(file, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)
20
  text = outputs["text"]
21
+ timestamps = outputs["chunks"]
22
+
23
+ if return_timestamps==True:
24
+ timestamps = [f"[{format_timestamp(chunk['timestamp'][0])} -> {format_timestamp(chunk['timestamp'][1])}] {chunk['text']}" for chunk in timestamps]
25
+
26
+ else:
27
+ timestamps = [f"{chunk['text']}" for chunk in timestamps]
28
+
29
+ text = "\n".join(str(feature) for feature in timestamps)
30
  return text
31
 
32
+
33
  file_transcribe = gr.Interface(
34
  fn=transcribe,
35
  inputs=[
 
51
  allow_flagging="never",
52
  )
53
 
54
+ file_transcribe.launch(enable_queue=True, debug = True)