Views
No views yet
Files.English Version: I completely understand why many find it frustrating that 99% of modern AI models, including this one, are trained for multilingual speech recognition. This creates an inconvenience for users who require specific languages for their target use cases. Here you will find a fully functional solution to this issue, including all the files required by both end-users and developers.

files directory.forced_decoder_ids = None) и 5000 шагов агрессивного обучения из модели были полностью вытеснены ассоциативные связи для 98 сторонних языков.eval_loss: 0.1929 был успешно достигнут на 4500-м шаге.gradient_checkpointing=True.gradient_accumulation_steps=4).learning_rate=5e-5 и warmup_steps=300.forced_decoder_ids = None) and applying 5000 steps of aggressive training, associative connections for 98 third-party languages were completely displaced from the model.eval_loss of 0.1929 was successfully achieved at step 4500.gradient_checkpointing=True activation method were applied.gradient_accumulation_steps=4).learning_rate=5e-5 and warmup_steps=300.1import torch
2import librosa
3from transformers import WhisperProcessor, WhisperForConditionalGeneration
4
5# 1. Загрузка процессора и модели из репозитория
6model_id = "akimbabananan/whisper-base-ru-en-only"
7device = "cuda" if torch.cuda.is_available() else "cpu"
8
9processor = WhisperProcessor.from_pretrained(model_id)
10model = WhisperForConditionalGeneration.from_pretrained(model_id).to(device)
11
12# 2. Подготовка аудио (укажите путь к вашему файлу)
13audio_path = "your_audio_file.wav"
14audio_input, sampling_rate = librosa.load(audio_path, sr=16000)
15
16# 3. Преобразование в признаки и генерация текста
17input_features = processor(audio_input, sampling_rate=sampling_rate, return_tensors="pt").input_features.to(device)
18forced_decoder_ids = processor.get_decoder_prompt_ids(language="russian", task="transcribe")
19
20with torch.no_grad():
21 predicted_ids = model.generate(input_features, forced_decoder_ids=forced_decoder_ids)
22
23# 4. Вывод результата (извлекаем [0], чтобы получить чистую строку)
24transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
25print(f"Результат распознавания: {transcription}")
26