Dorjzodovsuren commited on
Commit
60a396e
·
verified ·
1 Parent(s): fbf7113

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -4,7 +4,7 @@ import pytubefix as pt
4
  import os, time, librosa, torch
5
  from pyannote.audio import Pipeline
6
  from transformers import pipeline
7
- from google.colab import userdata
8
 
9
 
10
  def second_to_timecode(x: float) -> str:
@@ -60,7 +60,7 @@ asr_pipeline = pipeline(
60
  tokenizer=processor.tokenizer,
61
  feature_extractor=processor.feature_extractor,
62
  chunk_length_s=chunk_length_s,
63
- device=device
64
  )
65
 
66
  lang = 'mn'
@@ -68,6 +68,8 @@ asr_pipeline.model.config.forced_decoder_ids = asr_pipeline.tokenizer.get_decode
68
 
69
  print("----------> Loaded models <-----------")
70
 
 
 
71
  def generator(youtube_link, microphone, file_upload, num_speakers, max_duration, history):
72
 
73
  if int(youtube_link != '') + int(microphone is not None) + int(file_upload is not None) != 1:
 
4
  import os, time, librosa, torch
5
  from pyannote.audio import Pipeline
6
  from transformers import pipeline
7
+ import spaces
8
 
9
 
10
  def second_to_timecode(x: float) -> str:
 
60
  tokenizer=processor.tokenizer,
61
  feature_extractor=processor.feature_extractor,
62
  chunk_length_s=chunk_length_s,
63
+ device_map="auto"
64
  )
65
 
66
  lang = 'mn'
 
68
 
69
  print("----------> Loaded models <-----------")
70
 
71
+ gpu_timeout = int(os.getenv("GPU_TIMEOUT", 60))
72
+ @spaces.GPU(duration=gpu_timeout)
73
  def generator(youtube_link, microphone, file_upload, num_speakers, max_duration, history):
74
 
75
  if int(youtube_link != '') + int(microphone is not None) + int(file_upload is not None) != 1: