Spaces:
Sleeping
Sleeping
Sasha commited on
Commit ·
d7b1f0b
1
Parent(s): d0dc16f
feat: tune Whisper settings and add word mappings
Browse filesFiles changed (4)
1google-site-verification: google7181fa1faffcf274.html36 unmodified lines373839404142214 unmodified lines257258259260261262263264265266124 unmodified lines39139239339439539639736 unmodified linesWHISPER_MODEL_SIZE = os.getenv("WHISPER_MODEL", "base")WHISPER_DEVICE = os.getenv("WHISPER_DEVICE", "cpu")WHISPER_COMPUTE_TYPE = os.getenv("WHISPER_COMPUTE_TYPE", "int8")if not API_KEY:print("[Error] API_KEY is missing in .env! Cannot push data to backend.")214 unmodified linesbeam_size=5,language="ru",temperature=0.0,log_prob_threshold=-0.8,no_speech_threshold=0.6,vad_filter=True,vad_parameters=dict(min_silence_duration_ms=500))words_list = []124 unmodified linesmodel = WhisperModel(WHISPER_MODEL_SIZE,device=WHISPER_DEVICE,compute_type=WHISPER_COMPUTE_TYPE)transcribe_vod_audio(vod_id, created_at, model)except Exception as e:36 unmodified lines37383940414243214 unmodified lines258259260261262263264265266267268124 unmodified lines39339439539639739839940036 unmodified linesWHISPER_MODEL_SIZE = os.getenv("WHISPER_MODEL", "base")WHISPER_DEVICE = os.getenv("WHISPER_DEVICE", "cpu")WHISPER_COMPUTE_TYPE = os.getenv("WHISPER_COMPUTE_TYPE", "int8")WHISPER_CPU_THREADS = int(os.getenv("WHISPER_CPU_THREADS", "2"))if not API_KEY:print("[Error] API_KEY is missing in .env! Cannot push data to backend.")214 unmodified linesbeam_size=5,language="ru",temperature=0.0,condition_on_previous_text=False,log_prob_threshold=-0.8,no_speech_threshold=0.6,vad_filter=True,vad_parameters=dict(threshold=0.5, min_silence_duration_ms=500))words_list = []124 unmodified linesmodel = WhisperModel(WHISPER_MODEL_SIZE,device=WHISPER_DEVICE,compute_type=WHISPER_COMPUTE_TYPE,cpu_threads=WHISPER_CPU_THREADS)transcribe_vod_audio(vod_id, created_at, model)except Exception as e:
43 unmodified lines444546474849166 unmodified lines21621721821922022122222322422522622712 unmodified lines240241242243244245246247248249266 unmodified lines51651751851952052152252352452543 unmodified linesWHISPER_MODEL_SIZE = os.getenv("WHISPER_MODEL", "base")WHISPER_DEVICE = os.getenv("WHISPER_DEVICE", "cpu")WHISPER_COMPUTE_TYPE = os.getenv("WHISPER_COMPUTE_TYPE", "int8")# Verify essential secretsif not API_KEY:166 unmodified linesdef init_whisper_model():"""Load Faster-Whisper model into memory"""print(f"[Whisper] Loading model '{WHISPER_MODEL_SIZE}' on {WHISPER_DEVICE} ({WHISPER_COMPUTE_TYPE})...")# This might take a few minutes on first run as the model downloadsmodel = WhisperModel(WHISPER_MODEL_SIZE,device=WHISPER_DEVICE,compute_type=WHISPER_COMPUTE_TYPE)print("[Whisper] Model loaded successfully.")return model12 unmodified linesbeam_size=5,language="ru",temperature=0.0,log_prob_threshold=-0.8,no_speech_threshold=0.6,vad_filter=True, # Voice Activity Detection filters out silencevad_parameters=dict(min_silence_duration_ms=500))words_list = []266 unmodified linesbeam_size=5,language="ru",temperature=0.0,log_prob_threshold=-0.8,no_speech_threshold=0.6,vad_filter=True,vad_parameters=dict(min_silence_duration_ms=500))words_list = []for segment in segments:43 unmodified lines44454647484950166 unmodified lines21721821922022122222322422522622722822912 unmodified lines242243244245246247248249250251252266 unmodified lines51952052152252352452552652752852943 unmodified linesWHISPER_MODEL_SIZE = os.getenv("WHISPER_MODEL", "base")WHISPER_DEVICE = os.getenv("WHISPER_DEVICE", "cpu")WHISPER_COMPUTE_TYPE = os.getenv("WHISPER_COMPUTE_TYPE", "int8")WHISPER_CPU_THREADS = int(os.getenv("WHISPER_CPU_THREADS", "2"))# Verify essential secretsif not API_KEY:166 unmodified linesdef init_whisper_model():"""Load Faster-Whisper model into memory"""print(f"[Whisper] Loading model '{WHISPER_MODEL_SIZE}' on {WHISPER_DEVICE} ({WHISPER_COMPUTE_TYPE}, threads={WHISPER_CPU_THREADS})...")# This might take a few minutes on first run as the model downloadsmodel = WhisperModel(WHISPER_MODEL_SIZE,device=WHISPER_DEVICE,compute_type=WHISPER_COMPUTE_TYPE,cpu_threads=WHISPER_CPU_THREADS)print("[Whisper] Model loaded successfully.")return model12 unmodified linesbeam_size=5,language="ru",temperature=0.0,condition_on_previous_text=False,log_prob_threshold=-0.8,no_speech_threshold=0.6,vad_filter=True, # Voice Activity Detection filters out silencevad_parameters=dict(threshold=0.5, min_silence_duration_ms=500))words_list = []266 unmodified linesbeam_size=5,language="ru",temperature=0.0,condition_on_previous_text=False,log_prob_threshold=-0.8,no_speech_threshold=0.6,vad_filter=True,vad_parameters=dict(threshold=0.5, min_silence_duration_ms=500))words_list = []for segment in segments:
531 unmodified lines5325335345355365378 unmodified lines54654754854955055155255348 unmodified lines602603604605606607608609531 unmodified lines'here', 'whats', 'what', 'which', 'who', 'whom', 'whose', 'why', 'how', 'can', 'will', 'just']);// Get word frequencies (Voice vs Chat messages from streamer)app.get('/api/stats/words', cacheMiddleware(), async (req, res) => {const streamId = req.query.stream_id ? parseInt(req.query.stream_id) : null;8 unmodified linesfor (const w of rawWords) {if (!w || !w.word || typeof w.word !== 'string') continue;let clean = w.word.toLowerCase().trim();if (clean === 'блядь') {clean = 'блять';}const isAllowedLength = clean.length >= 3 || clean === 'ну';48 unmodified lines}if (!word) continue;if (word === 'блядь') {word = 'блять';}const isAllowedLength = word.length >= 3 || word === 'ну';531 unmodified lines5325335345355365375385395405415425435445455465475485498 unmodified lines55855956056156256356456548 unmodified lines614615616617618619620621531 unmodified lines'here', 'whats', 'what', 'which', 'who', 'whom', 'whose', 'why', 'how', 'can', 'will', 'just']);// Word mappings/synonyms to group similar pronunciations or typosconst WORD_MAPPINGS = {'блядь': 'блять','петерка': 'пятерка','питерка': 'пятерка','петёрка': 'пятерка','пётерка': 'пятерка','кримбал': 'кримбр','кримбл': 'кримбр','кримбор': 'кримбр'};// Get word frequencies (Voice vs Chat messages from streamer)app.get('/api/stats/words', cacheMiddleware(), async (req, res) => {const streamId = req.query.stream_id ? parseInt(req.query.stream_id) : null;8 unmodified linesfor (const w of rawWords) {if (!w || !w.word || typeof w.word !== 'string') continue;let clean = w.word.toLowerCase().trim();if (WORD_MAPPINGS[clean]) {clean = WORD_MAPPINGS[clean];}const isAllowedLength = clean.length >= 3 || clean === 'ну';48 unmodified lines}if (!word) continue;if (WORD_MAPPINGS[word]) {word = WORD_MAPPINGS[word];}const isAllowedLength = word.length >= 3 || word === 'ну';
google7181fa1faffcf274.htmlAdded+1
local_worker/vod_backfiller.py+5-2
local_worker/worker.py+8-4
server/server.js+16-4