aichina commited on
Commit
6e941de
1 Parent(s): e141a07
Files changed (1) hide show
  1. app.py +1 -24
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import gradio as gr
2
- import whisper
3
  from pytube import YouTube
4
 
5
 
@@ -12,14 +12,6 @@ headers = {
12
  # 'Content-Type': 'multipart/form-data',
13
  }
14
 
15
- # files = {
16
- # 'audio': ("707539ca80d090a28c5ea7bbf93e8068.mp4", open('707539ca80d090a28c5ea7bbf93e8068.mp4', 'rb'), 'video/mp4'),
17
- # 'audio_url': (None, 'http://files.gladia.io/example/audio-transcription/split_infinity.wav'),
18
- # 'language': (None, 'english'),
19
- # 'language_behaviour': (None, 'automatic single language'),
20
- # }
21
-
22
- # response = requests.post('https://api.gladia.io/audio/text/audio-transcription/', headers=headers, files=files)
23
 
24
  def convert(res):
25
  data = res.json()
@@ -49,22 +41,7 @@ def get_transcript(url, model_size, lang, format):
49
  response = requests.post('https://api.gladia.io/audio/text/audio-transcription/', headers=headers, files=files)
50
  return convert(response)
51
 
52
- def get_transcript2(url, model_size, lang, format):
53
-
54
-
55
- print('whisper loading ...')
56
- model = whisper.load_model(model_size)
57
- print('whisper over')
58
-
59
- if lang == "None":
60
- lang = None
61
-
62
- result = model.transcribe(get_audio(url), fp16=False, language=lang)
63
 
64
- if format == "None":
65
- return result["text"]
66
- elif format == ".srt":
67
- return format_to_srt(result["segments"])
68
 
69
  def format_to_srt(segments):
70
  output = ""
 
1
  import gradio as gr
2
+
3
  from pytube import YouTube
4
 
5
 
 
12
  # 'Content-Type': 'multipart/form-data',
13
  }
14
 
 
 
 
 
 
 
 
 
15
 
16
  def convert(res):
17
  data = res.json()
 
41
  response = requests.post('https://api.gladia.io/audio/text/audio-transcription/', headers=headers, files=files)
42
  return convert(response)
43
 
 
 
 
 
 
 
 
 
 
 
 
44
 
 
 
 
 
45
 
46
  def format_to_srt(segments):
47
  output = ""