Mei000 commited on
Commit
bc07ca5
1 Parent(s): ca355a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -16,14 +16,6 @@ class GradioInference():
16
  voice=path[0].download()
17
  results_text = self.loaded_model(voice)["segments"]
18
  return self.srt(results_text)
19
-
20
-
21
- def format_time(self, time):
22
- hours = time//3600
23
- minutes = (time - hours*3600)//60
24
- seconds = time - hours*3600 - minutes*60
25
- milliseconds = (time - int(time))*1000
26
- return f"{int(hours):02d}:{int(minutes):02d}:{int(seconds):02d},{int(milliseconds):03d}"
27
 
28
  def srt(self, segments):
29
  output = ""
@@ -32,7 +24,13 @@ class GradioInference():
32
  output += f"{self.format_time(segment['start'])} --> {self.format_time(segment['end'])}\n"
33
  output += f"{segment['text']}\n\n"
34
  return output
35
-
 
 
 
 
 
 
36
 
37
 
38
  def populate_metadata(self, link):
@@ -61,7 +59,6 @@ with block:
61
  with gr.Group():
62
  with gr.Box():
63
  with gr.Row().style(equal_height=True):
64
- wt = gr.Radio(["None", ".srt", ".csv"], label="With Timestamps?")
65
  link = gr.Textbox(label="YouTube Link")
66
  title = gr.Label(label="Video Title")
67
  with gr.Row().style(equal_height=True):
@@ -69,6 +66,6 @@ with block:
69
  text = gr.Textbox(label="Transcription", placeholder="Transcription Output", lines=10)
70
  with gr.Row().style(equal_height=True):
71
  btn = gr.Button("Transcribe")
72
- btn.click(gio, inputs=[link, wt], outputs=[text])
73
  link.change(gio.populate_metadata, inputs=[link], outputs=[img, title])
74
  block.launch()
 
16
  voice=path[0].download()
17
  results_text = self.loaded_model(voice)["segments"]
18
  return self.srt(results_text)
 
 
 
 
 
 
 
 
19
 
20
  def srt(self, segments):
21
  output = ""
 
24
  output += f"{self.format_time(segment['start'])} --> {self.format_time(segment['end'])}\n"
25
  output += f"{segment['text']}\n\n"
26
  return output
27
+
28
+ def format_time(self, time):
29
+ hours = time//3600
30
+ minutes = (time - hours*3600)//60
31
+ seconds = time - hours*3600 - minutes*60
32
+ milliseconds = (time - int(time))*1000
33
+ return f"{int(hours):02d}:{int(minutes):02d}:{int(seconds):02d},{int(milliseconds):03d}"
34
 
35
 
36
  def populate_metadata(self, link):
 
59
  with gr.Group():
60
  with gr.Box():
61
  with gr.Row().style(equal_height=True):
 
62
  link = gr.Textbox(label="YouTube Link")
63
  title = gr.Label(label="Video Title")
64
  with gr.Row().style(equal_height=True):
 
66
  text = gr.Textbox(label="Transcription", placeholder="Transcription Output", lines=10)
67
  with gr.Row().style(equal_height=True):
68
  btn = gr.Button("Transcribe")
69
+ btn.click(gio, inputs=[link], outputs=[text])
70
  link.change(gio.populate_metadata, inputs=[link], outputs=[img, title])
71
  block.launch()