palli23 commited on
Commit
523244e
·
1 Parent(s): fd7965b

fix transcribe bug

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # app.py – Virkar fullkomlega á ZeroGPU + venjulegum GPU Spaces
2
  import os
3
  import gradio as gr
4
  import spaces
@@ -6,19 +6,23 @@ from transformers import pipeline
6
 
7
  MODEL_NAME = "palli23/whisper-small-sam_spjall"
8
 
9
- # Látum mótið hlaðast einu sinni við ræsingu – ÞETTA ER MIKILVÆGT
10
  print("Hleð Whisper módelinu einu sinni...")
11
 
12
  pipe = pipeline(
13
  "automatic-speech-recognition",
14
  model=MODEL_NAME,
15
- torch_dtype="auto", # fínt fyrir bæði fp16 og fp32
16
- device="cuda" if os.getenv("SYSTEM") == "spaces" else "cpu", # ZeroGPU skynjar CUDA sjálfkrafa
17
- model_kwargs={"attn_implementation": "sdpa"}, # hraðari á nýjum GPU-um
18
  token=os.getenv("HF_TOKEN")
19
  )
20
 
21
- print("Módel tilbúið allt klárt!")
 
 
 
 
 
22
 
23
  @spaces.GPU(duration=120)
24
  def transcribe_audio(audio_path):
@@ -29,8 +33,9 @@ def transcribe_audio(audio_path):
29
  audio_path,
30
  chunk_length_s=30,
31
  batch_size=8,
32
- generate_kwargs={"language": "is", "task": "transcribe"},
33
- return_timestamps=False
 
34
  )
35
  return result["text"]
36
 
 
1
+ # app.py – Fixed for outdated generation_config (virkar á ZeroGPU)
2
  import os
3
  import gradio as gr
4
  import spaces
 
6
 
7
  MODEL_NAME = "palli23/whisper-small-sam_spjall"
8
 
 
9
  print("Hleð Whisper módelinu einu sinni...")
10
 
11
  pipe = pipeline(
12
  "automatic-speech-recognition",
13
  model=MODEL_NAME,
14
+ torch_dtype="auto",
15
+ device="cuda" if os.getenv("SYSTEM") == "spaces" else "cpu",
16
+ model_kwargs={"attn_implementation": "sdpa"},
17
  token=os.getenv("HF_TOKEN")
18
  )
19
 
20
+ # *** THIS IS THE FIX: Uppfæra generation_config til að styðja language/task ***
21
+ pipe.model.generation_config.language = "is" # Default language
22
+ pipe.model.generation_config.task = "transcribe" # Default task
23
+ pipe.model.generation_config.forced_decoder_ids = None # Disable old forced IDs (deprecated)
24
+ pipe.model.generation_config.suppress_tokens = [] # Clear suppress if needed
25
+ print("Generation config uppfærð – allt klárt!")
26
 
27
  @spaces.GPU(duration=120)
28
  def transcribe_audio(audio_path):
 
33
  audio_path,
34
  chunk_length_s=30,
35
  batch_size=8,
36
+ return_timestamps=False,
37
+ # Núna virkar þetta án generate_kwargs (því config er sett)
38
+ # Ef þú vilt breyta: generate_kwargs={"language": "is", "task": "transcribe"}
39
  )
40
  return result["text"]
41