0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

音声選択できる日本語読み上げアプリを作った(Speech04)

0
Posted at

音声選択できる日本語読み上げアプリを作った(Speech04)

はじめに

以前作った音声読み上げアプリ(Speech03)を改良して、
音声の種類を選べるようにしてみました。


完成したもの

テキストを入力して、音声を選択すると読み上げできます。

ダウンロードはこちら👇
https://km.kokage.cc/


できること

  • 日本語テキストの読み上げ
  • 音声(モデル)の選択
  • 音声ファイルのダウンロード

使用技術

  • Python
  • Streamlit
  • Coqui TTS
  • PyTorch(CPU版)

工夫したところ

音声選択機能

複数のTTSモデルを選択できるようにしました。

model_list = {
    "日本語(自然)": "tts_models/ja/kokoro/tacotron2-DDC",
    "日本語(軽量)": "tts_models/ja/kokoro/vits",
    "英語(サンプル)": "tts_models/en/ljspeech/tacotron2-DDC"
}

モデルロードの高速化

キャッシュを使って読み込みを高速化しています。

@st.cache_resource
def load_tts(model_name):
    return TTS(model_name=model_name)

音声ダウンロード機能

st.download_button(
    label="音声をダウンロード",
    data=audio_bytes,
    file_name="speech.wav",
    mime="audio/wav"
)

ハマったところ

短い文章でエラー

Tacotron系モデルで以下のエラーが出ました。

カーネルサイズは実際の入力サイズより大きくすることはできません

原因:
→ テキストが短すぎる

対応:
→ 文字数チェックを追加


まとめ

Speech03からの改良で、
より実用的なアプリにできました。

音声を選べるだけで、使っていて楽しくなります。


おわりに

まだ改善できるところはありますが、
一旦v1.0として公開しました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?