🚀 whisper-fa-tinyyy
このモデルは、openai/whisper-tiny を common_voice_11_0 データセットでファインチューニングしたバージョンです。評価セットでは以下の結果を達成しています。
🚀 クイックスタート
このモデルは、自動音声認識タスクに使用できます。以下のコード例は、Colabでこのモデルを使用する方法を示しています。
基本的な使用法
!pip install torch torchaudio transformers pydub google-colab
import torch
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
from pydub import AudioSegment
import os
from google.colab import files
model_id = "hackergeek98/whisper-fa-tinyyy"
device = "cuda" if torch.cuda.is_available() else "cpu"
model = AutoModelForSpeechSeq2Seq.from_pretrained(model_id).to(device)
processor = AutoProcessor.from_pretrained(model_id)
whisper_pipe = pipeline(
"automatic-speech-recognition", model=model, tokenizer=processor.tokenizer, feature_extractor=processor.feature_extractor, device=0 if torch.cuda.is_available() else -1
)
def convert_to_wav(audio_path):
audio = AudioSegment.from_file(audio_path)
wav_path = "converted_audio.wav"
audio.export(wav_path, format="wav")
return wav_path
def split_audio(audio_path, chunk_length_ms=30000):
audio = AudioSegment.from_wav(audio_path)
chunks = [audio[i:i+chunk_length_ms] for i in range(0, len(audio), chunk_length_ms)]
chunk_paths = []
for i, chunk in enumerate(chunks):
chunk_path = f"chunk_{i}.wav"
chunk.export(chunk_path, format="wav")
chunk_paths.append(chunk_path)
return chunk_paths
def transcribe_long_audio(audio_path):
wav_path = convert_to_wav(audio_path)
chunk_paths = split_audio(wav_path)
transcription = ""
for chunk in chunk_paths:
result = whisper_pipe(chunk)
transcription += result["text"] + "\n"
os.remove(chunk)
os.remove(wav_path)
text_path = "transcription.txt"
with open(text_path, "w") as f:
f.write(transcription)
return text_path
uploaded = files.upload()
audio_file = list(uploaded.keys())[0]
transcription_file = transcribe_long_audio(audio_file)
files.download(transcription_file)
✨ 主な機能
- このモデルは、自動音声認識タスクに使用できます。
- ファインチューニングにより、特定のデータセットに適した性能を発揮します。
📦 インストール
Colabで使用する場合、以下のコマンドで必要なパッケージをインストールできます。
!pip install torch torchaudio transformers pydub google-colab
🔧 技術詳細
学習ハイパーパラメータ
学習中に使用されたハイパーパラメータは以下の通りです。
- 学習率: 0.0001
- 学習バッチサイズ: 8
- 評価バッチサイズ: 8
- シード: 42
- 勾配蓄積ステップ: 4
- 総学習バッチサイズ: 32
- オプティマイザ: OptimizerNames.ADAMW_TORCHを使用し、ベータ=(0.9,0.999)、イプシロン=1e-08、追加のオプティマイザ引数はなし
- 学習率スケジューラタイプ: 線形
- 学習率スケジューラウォームアップステップ: 500
- エポック数: 1
- 混合精度学習: Native AMP
学習結果
学習損失 |
エポック |
ステップ |
検証損失 |
0.0186 |
0.9998 |
2357 |
0.0246 |
フレームワークバージョン
- Transformers 4.49.0
- Pytorch 2.6.0+cu124
- Datasets 3.4.1
- Tokenizers 0.21.1
📄 ライセンス
このモデルはMITライセンスの下で提供されています。