camparchimedes commited on
Commit
aea18b3
β€’
1 Parent(s): 930fb43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -23,7 +23,7 @@ model.to(device)
23
 
24
  def transcribe_audio(audio_file):
25
  audio_input, sample_rate = sf.read(audio_file)
26
- chunk_size = 16000 * 28 # 28 seconds chunks (seems to work best)
27
  chunks = [audio_input[i:i + chunk_size] for i in range(0, len(audio_input), chunk_size)]
28
 
29
  transcription = ""
@@ -33,8 +33,8 @@ def transcribe_audio(audio_file):
33
  with torch.no_grad():
34
  output = model.generate(
35
  inputs.input_features,
36
- max_length=2048, # Increase max_length for longer outputs
37
- num_beams=10,
38
  task="transcribe",
39
  language="no"
40
  )
@@ -42,7 +42,7 @@ def transcribe_audio(audio_file):
42
 
43
  return transcription.strip()
44
 
45
- # HTML for banner image
46
  banner_html = """
47
  <div style="text-align: center;">
48
  <img src="https://huggingface.co/spaces/camparchimedes/ola_s-audioshop/raw/main/Olas%20AudioSwitch%20Shop.png" alt="Banner" width="87%; height:auto;">
@@ -54,12 +54,12 @@ iface = gr.Blocks()
54
 
55
  with iface:
56
  gr.HTML(banner_html)
57
- gr.Markdown("# Ola's AudioSwitch2Go πŸ”ŠπŸŽ§β˜•πŸ§‘πŸΌβ€πŸ«@{NbAiLab/whisper-norwegian-medium}\nUpload audio file (if .ma4 ~simply rename it to .mp3 before upload)")
58
  audio_input = gr.Audio(type="filepath")
59
  transcription_output = gr.Textbox()
60
  transcribe_button = gr.Button("Transcribe")
61
 
62
  transcribe_button.click(fn=transcribe_audio, inputs=audio_input, outputs=transcription_output)
63
 
64
- # Launch the interface
65
  iface.launch(share=True, debug=True)
 
23
 
24
  def transcribe_audio(audio_file):
25
  audio_input, sample_rate = sf.read(audio_file)
26
+ chunk_size = 16000 * 28 # 28 seconds chunks, seems to work best
27
  chunks = [audio_input[i:i + chunk_size] for i in range(0, len(audio_input), chunk_size)]
28
 
29
  transcription = ""
 
33
  with torch.no_grad():
34
  output = model.generate(
35
  inputs.input_features,
36
+ max_length=1024, # Increase max_length@longer outputs
37
+ num_beams=5,
38
  task="transcribe",
39
  language="no"
40
  )
 
42
 
43
  return transcription.strip()
44
 
45
+ # HTML |banner image
46
  banner_html = """
47
  <div style="text-align: center;">
48
  <img src="https://huggingface.co/spaces/camparchimedes/ola_s-audioshop/raw/main/Olas%20AudioSwitch%20Shop.png" alt="Banner" width="87%; height:auto;">
 
54
 
55
  with iface:
56
  gr.HTML(banner_html)
57
+ gr.Markdown("# Nvidia A100πŸ‘‹πŸΌπŸ‘ΎπŸ¦Ύβš‘β˜•πŸ§‘πŸΌβ€πŸ«@{NbAiLab/whisper-norwegian-medium}\nUpload audio file (*needs to be in .mp3 format before upload*)")
58
  audio_input = gr.Audio(type="filepath")
59
  transcription_output = gr.Textbox()
60
  transcribe_button = gr.Button("Transcribe")
61
 
62
  transcribe_button.click(fn=transcribe_audio, inputs=audio_input, outputs=transcription_output)
63
 
64
+ # Launch interface
65
  iface.launch(share=True, debug=True)