palli23 commited on
Commit
3185e6d
·
verified ·
1 Parent(s): e37e472

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -17
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # app.py
2
  import os
3
  os.environ["OMP_NUM_THREADS"] = "1"
4
  os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:128"
@@ -18,20 +18,19 @@ def get_pipe():
18
  "automatic-speech-recognition",
19
  model=MODEL_NAME,
20
  torch_dtype="float16",
21
- device=0, # T4 GPU
22
- token=os.getenv("HF_TOKEN"), # Remove line if model is public
23
  )
24
 
25
- pipe = get_pipe() # ← Loaded once when Space starts
26
-
27
 
28
  # ——————————————————————————————
29
- # Transcription function (super fast now)
30
  # ——————————————————————————————
31
  def transcribe_3min(audio_path):
32
  if not audio_path:
33
  return "Hladdu upp hljóðskrá"
34
-
35
  result = pipe(
36
  audio_path,
37
  chunk_length_s=30,
@@ -41,32 +40,43 @@ def transcribe_3min(audio_path):
41
  )
42
  return result["text"]
43
 
44
-
45
  # ——————————————————————————————
46
- # Gradio UI
47
  # ——————————————————————————————
48
- with gr.Blocks(title="Íslenskt ASR – 3 mín") as demo:
49
- gr.Markdown("# Íslenskt ASR – 3 mínútur")
50
- gr.Markdown("**Whisper · mjög lágur WER · allt að 5 mín hljóð**")
 
 
 
 
 
 
 
51
 
52
  audio_in = gr.Audio(
53
  type="filepath",
54
  label="Hladdu upp .mp3 / .wav (max 5 mín)"
55
  )
56
  btn = gr.Button("Transcribe", variant="primary", size="lg")
57
- output = gr.Textbox(lines=30, label="Útskrift")
58
 
59
  btn.click(fn=transcribe_3min, inputs=audio_in, outputs=output)
60
 
 
 
 
 
 
61
 
62
  # ——————————————————————————————
63
- # Stable launch (no more infinite Building)
64
  # ——————————————————————————————
65
  demo.launch(
66
- auth=("beta", "beta2025"),
67
- ssr_mode=False,
68
- show_error=True,
69
  server_name="0.0.0.0",
70
  server_port=7860,
 
71
  quiet=False
72
  )
 
1
+ # app.py — Íslenskt ASR – 3 mínútur (public, no login, with contact)
2
  import os
3
  os.environ["OMP_NUM_THREADS"] = "1"
4
  os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "max_split_size_mb:128"
 
18
  "automatic-speech-recognition",
19
  model=MODEL_NAME,
20
  torch_dtype="float16",
21
+ device=0,
22
+ token=os.getenv("HF_TOKEN"),
23
  )
24
 
25
+ pipe = get_pipe()
 
26
 
27
  # ——————————————————————————————
28
+ # Transcription function
29
  # ——————————————————————————————
30
  def transcribe_3min(audio_path):
31
  if not audio_path:
32
  return "Hladdu upp hljóðskrá"
33
+
34
  result = pipe(
35
  audio_path,
36
  chunk_length_s=30,
 
40
  )
41
  return result["text"]
42
 
 
43
  # ——————————————————————————————
44
+ # Beautiful public UI with your contact
45
  # ——————————————————————————————
46
+ with gr.Blocks(title="Íslenskt ASR – 3 mínútur", theme=gr.themes.Soft()) as demo:
47
+ gr.HTML("""
48
+ <h1 style="text-align:center; margin-bottom:0;">Íslenskt ASR 3 mínútur</h1>
49
+ <h2 style="text-align:center; color:#1e88e5; margin-top:8px;">mjög lágur WER • allt að 5 mín hljóð</h2>
50
+ <p style="text-align:center; font-size:1.1em;">
51
+ pall23/whisper-small-sam_spjall<br>
52
+ <strong>Hafa samband:</strong>
53
+ <a href="mailto:pallinr1@protonmail.com" style="color:#d32f2f;">pallinr1@protonmail.com</a>
54
+ </p>
55
+ """)
56
 
57
  audio_in = gr.Audio(
58
  type="filepath",
59
  label="Hladdu upp .mp3 / .wav (max 5 mín)"
60
  )
61
  btn = gr.Button("Transcribe", variant="primary", size="lg")
62
+ output = gr.Textbox(lines=30, label="Útskrift", show_copy_button=True)
63
 
64
  btn.click(fn=transcribe_3min, inputs=audio_in, outputs=output)
65
 
66
+ gr.Markdown("""
67
+ <p style="text-align:center; font-size:0.9em; color:#666; margin-top:30px;">
68
+ Ókeypis • Keyrt á Hugging Face • pall23 © 2025
69
+ </p>
70
+ """)
71
 
72
  # ——————————————————————————————
73
+ # PUBLIC no login, no password
74
  # ——————————————————————————————
75
  demo.launch(
76
+ auth=None, # ← No login at all
77
+ share=True, # ← Public link
 
78
  server_name="0.0.0.0",
79
  server_port=7860,
80
+ show_error=True,
81
  quiet=False
82
  )