camparchimedes commited on
Commit
378420c
·
verified ·
1 Parent(s): 5a59081

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -13
app.py CHANGED
@@ -53,15 +53,8 @@ SIDEBAR_INFO = f"""
53
  <div align=center>
54
  <img src="{LOGO}" width=100/>"""
55
 
56
-
57
  warnings.filterwarnings("ignore")
58
 
59
- def convert_to_wav(audio_file):
60
- audio = AudioSegment.from_file(audio_file, format="m4a")
61
- wav_file = "temp.wav"
62
- audio.export(wav_file, format="wav")
63
- return wav_file
64
-
65
  #def convert_to_wav(filepath):
66
  #_,file_ending = os.path.splitext(f'{filepath}')
67
  #audio_file = filepath.replace(file_ending, ".wav")
@@ -70,6 +63,11 @@ def convert_to_wav(audio_file):
70
  #return audio_file
71
 
72
  #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
 
 
 
 
73
 
74
  device = "cuda" if torch.cuda.is_available() else "cpu"
75
 
@@ -106,11 +104,9 @@ def transcribe_audio(audio_file, batch_size=4):
106
  *Memory: {memory.total / (1024 * 1024 * 1024):.2f}GB, used: {memory.percent}%, available: {memory.available / (1024 * 1024 * 1024):.2f}GB.*
107
  *Processing time: {time_diff:.5} seconds.*
108
  *GPU Utilization: {gpu_utilization}%, GPU Memory: {gpu_memory}"""
109
-
110
-
111
  #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
112
 
113
- # Clean and preprocess text
114
  def clean_text(text):
115
  text = re.sub(r'https?:\/\/.*[\r\n]*', '', text)
116
  text = re.sub(r'[^\w\s]', '', text)
@@ -229,9 +225,8 @@ PLACEHOLDER = """
229
  """
230
 
231
  with iface:
232
- #gr.HTML('<img src="https://huggingface.co/spaces/camparchimedes/ola_s-audioshop/blob/main/pic09w9678yhit.png" alt="" style="width: 100%; height: auto; opacity: 0.55; >')
233
- #gr.Markdown("**Switch Work webapp for transkribering av lydfiler til norsk skrift. Språkmodell: NbAiLab/nb-whisper-large, Ekstra: oppsummering, pdf-download**")
234
- gr.Image({LOGO})
235
  gr.HTML(SIDEBAR_INFO)
236
  gr.Markdown(HEADER_INFO)
237
 
 
53
  <div align=center>
54
  <img src="{LOGO}" width=100/>"""
55
 
 
56
  warnings.filterwarnings("ignore")
57
 
 
 
 
 
 
 
58
  #def convert_to_wav(filepath):
59
  #_,file_ending = os.path.splitext(f'{filepath}')
60
  #audio_file = filepath.replace(file_ending, ".wav")
 
63
  #return audio_file
64
 
65
  #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
66
+ def convert_to_wav(audio_file):
67
+ audio = AudioSegment.from_file(audio_file, format="m4a")
68
+ wav_file = "temp.wav"
69
+ audio.export(wav_file, format="wav")
70
+ return wav_file
71
 
72
  device = "cuda" if torch.cuda.is_available() else "cpu"
73
 
 
104
  *Memory: {memory.total / (1024 * 1024 * 1024):.2f}GB, used: {memory.percent}%, available: {memory.available / (1024 * 1024 * 1024):.2f}GB.*
105
  *Processing time: {time_diff:.5} seconds.*
106
  *GPU Utilization: {gpu_utilization}%, GPU Memory: {gpu_memory}"""
 
 
107
  #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
108
 
109
+ # Clean/preprocess text
110
  def clean_text(text):
111
  text = re.sub(r'https?:\/\/.*[\r\n]*', '', text)
112
  text = re.sub(r'[^\w\s]', '', text)
 
225
  """
226
 
227
  with iface:
228
+
229
+ gr.Image(LOGO) # LOGO variable as string to gr.Image constructor
 
230
  gr.HTML(SIDEBAR_INFO)
231
  gr.Markdown(HEADER_INFO)
232