camparchimedes commited on
Commit
8b1327d
·
verified ·
1 Parent(s): a10f544

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -10,7 +10,6 @@ import os
10
  import warnings
11
  from pydub import AudioSegment
12
  import torch
13
- from torch import torchaudio
14
  from transformers import pipeline, WhisperForConditionalGeneration, WhisperProcessor
15
  from huggingface_hub import model_info
16
  import nltk
@@ -44,7 +43,7 @@ def convert_to_wav(audio_file):
44
  return wav_file
45
 
46
  # Initialize device for torch
47
- #device = "cuda" if torch.cuda.is_available() else "cpu"
48
 
49
  # Load smoking-big-pipe
50
  MODEL_NAME = "NbAiLab/nb-whisper-large"
@@ -185,15 +184,22 @@ def save_to_pdf(text, summary):
185
  pdf.output(pdf_output_path)
186
  return pdf_output_path
187
 
 
 
 
 
 
 
188
  # Gradio Interface
 
 
 
 
 
189
  iface = gr.Blocks()
190
 
191
  with iface:
192
- gr.HTML("""
193
- <div style="text-align: center;">
194
- <img src="https://huggingface.co/spaces/camparchimedes/transcription_app/raw/main/banner_trans.png" alt="" width="100%" height="auto">
195
- </div>
196
- """)
197
  gr.Markdown("# Vi har nå muligheten til å oversette lydfiler til norsk skrift.")
198
 
199
  with gr.Tabs():
 
10
  import warnings
11
  from pydub import AudioSegment
12
  import torch
 
13
  from transformers import pipeline, WhisperForConditionalGeneration, WhisperProcessor
14
  from huggingface_hub import model_info
15
  import nltk
 
43
  return wav_file
44
 
45
  # Initialize device for torch
46
+ device = "cuda" if torch.cuda.is_available() else "cpu"
47
 
48
  # Load smoking-big-pipe
49
  MODEL_NAME = "NbAiLab/nb-whisper-large"
 
184
  pdf.output(pdf_output_path)
185
  return pdf_output_path
186
 
187
+ def _return_img_html_embed(img_url):
188
+ HTML_str = (
189
+ f'<center> <img src="{img_url}" alt="Image" width="100%" height="auto"> </center>'
190
+ )
191
+ return HTML_str
192
+
193
  # Gradio Interface
194
+ def display_image():
195
+ img_url = "https://huggingface.co/spaces/camparchimedes/transcription_app/raw/main/banner_trans.png"
196
+ html_embed_str = _return_img_html_embed(img_url)
197
+ return html_embed_str
198
+
199
  iface = gr.Blocks()
200
 
201
  with iface:
202
+ gr.HTML(display_image())
 
 
 
 
203
  gr.Markdown("# Vi har nå muligheten til å oversette lydfiler til norsk skrift.")
204
 
205
  with gr.Tabs():