Spaces:
Build error
Build error
Commit ·
66efbc3
1
Parent(s): 9d6fa91
Update app.py
Browse files5 unmodified lines6789101119 unmodified lines3132333435363713 unmodified lines51525354555657585960615 unmodified linesMODEL_NAME = "openai/whisper-large-v2"BATCH_SIZE = 8device = 0 if torch.cuda.is_available() else "cpu"19 unmodified lines)elif (microphone is None) and (file_upload is None):return "ERROR: You have to either use the microphone or upload an audio file"file = microphone if microphone is not None else file_upload13 unmodified linesreturn HTML_strdef yt_transcribe(yt_url, task):yt = pt.YouTube(yt_url)html_embed_str = _return_yt_html_embed(yt_url)stream = yt.streams.filter(only_audio=True)[0]stream.download(filename="audio.mp3")pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id if task=="transcribe" else translate_token_id]]5 unmodified lines67891011121319 unmodified lines3334353637383940414243444513 unmodified lines59606162636465666768697071727374757677785 unmodified linesMODEL_NAME = "openai/whisper-large-v2"BATCH_SIZE = 8FILE_LIMIT_MB = 1000YT_ATTEMPT_LIMIT = 3device = 0 if torch.cuda.is_available() else "cpu"19 unmodified lines)elif (microphone is None) and (file_upload is None):raise gr.Error("You have to either use the microphone or upload an audio file")file_size_mb = os.stat(inputs).st_size / (1024 * 1024)if file_size_mb > FILE_LIMIT_MB:raise gr.Error(f"File size exceeds file size limit. Got file of size {file_size_mb:.2f}MB for a limit of {FILE_LIMIT_MB}MB.")file = microphone if microphone is not None else file_upload13 unmodified linesreturn HTML_strdef yt_transcribe(yt_url, task, max_filesize=75.0):yt = pt.YouTube(yt_url)html_embed_str = _return_yt_html_embed(yt_url)for attempt in range(YT_ATTEMPT_LIMIT):try:yt = pytube.YouTube(yt_url)stream = yt.streams.filter(only_audio=True)[0]breakexcept KeyError:if attempt + 1 == YT_ATTEMPT_LIMIT:raise gr.Error("An error occurred while loading the YouTube video. Please try again.")if stream.filesize_mb > max_filesize:raise gr.Error(f"Maximum YouTube file size is {max_filesize}MB, got {stream.filesize_mb:.2f}MB.")pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id if task=="transcribe" else translate_token_id]]
app.py+21-4