/nanoda

Use VOICEVOX CORE with ebitengine/purego

Primary LanguageGoMIT LicenseMIT

nanoda

License: MIT Go Reference Go Report Card CI

nanodaはVOICEVOX COREの動的ライブラリをGolangから叩くためのライブラリです。cgoではなくebitengine/puregoを利用しているため、簡単に使用することが可能です。

VOICEVOXについて

サポートするVOICEVOX COREのバージョンは 0.15 としており、開発は 0.15.0-preview.13 を元にしています。

nanoda自体はMITライセンスですが、利用に際してはVOICEVOXやOpenJTalkの利用規約に則る必要があることに注意してください。

使い方

go get github.com/aethiopicuschan/nanoda@latest

もっとも簡単な例は以下のようになります。

v, _ := nanoda.NewVoicevox("voicevox_core/libvoicevox_core.dylib", "voicevox_core/open_jtalk_dic_utf_8-1.11", "voicevox_core/model")
s, _ := v.NewSynthesizer()
s.LoadAllModels()
wav, _ := s.Tts("ずんだもんなのだ!", 3)
defer wav.Close()
f, _ := os.Create("output.wav")
defer f.Close()
io.Copy(f, wav)

その他 examples ディレクトリにサンプルコードを置いていますので、ご活用ください。

必要なファイルについて

動作には以下のものが必要です。

  • コアライブラリ
  • OpenJTalk
  • 音声モデル

VOICEVOX COREのREADMEに従って用意してください。ただし、上述のバージョンに対応するものを利用するようにしてください。

開発方針

以下の理由からなるべくnanoda側で処理を受け持ったり抽象化したりして機能を提供することを目指しています。

  • 使いやすさの向上
  • メモリまわりの安全性要件の確保
  • VOICEVOXとアプリケーション間の密結合を避け、APIの変更等に強くする

テスト

TODOです。ありません。

対応状況

以下は内部的に利用している関数のリストであり、必ずしも一致する形で公開されているわけではありません。

  • voicevox_create_supported_devices_json
  • voicevox_error_result_to_message
  • voicevox_get_version
  • voicevox_json_free
  • voicevox_make_default_initialize_options
  • voicevox_make_default_synthesis_options
  • voicevox_make_default_tts_options
  • voicevox_open_jtalk_rc_delete
  • voicevox_open_jtalk_rc_new
  • voicevox_open_jtalk_rc_use_user_dict
  • voicevox_synthesizer_create_accent_phrases
  • voicevox_synthesizer_create_accent_phrases_from_kana
  • voicevox_synthesizer_create_audio_query
  • voicevox_synthesizer_create_audio_query_from_kana
  • voicevox_synthesizer_create_metas_json
  • voicevox_synthesizer_delete
  • voicevox_synthesizer_is_gpu_mode
  • voicevox_synthesizer_is_loaded_voice_model
  • voicevox_synthesizer_load_voice_model
  • voicevox_synthesizer_new_with_initialize
  • voicevox_synthesizer_replace_mora_data
  • voicevox_synthesizer_replace_mora_pitch
  • voicevox_synthesizer_replace_phoneme_length
  • voicevox_synthesizer_synthesis
  • voicevox_synthesizer_tts
  • voicevox_synthesizer_tts_from_kana
  • voicevox_synthesizer_unload_voice_model
  • voicevox_user_dict_add_word
  • voicevox_user_dict_delete
  • voicevox_user_dict_import
  • voicevox_user_dict_load
  • voicevox_user_dict_new
  • voicevox_user_dict_remove_word
  • voicevox_user_dict_save
  • voicevox_user_dict_to_json
  • voicevox_user_dict_update_word
  • voicevox_user_dict_word_make
  • voicevox_voice_model_delete
  • voicevox_voice_model_get_metas_json
  • voicevox_voice_model_id
  • voicevox_voice_model_new_from_path
  • voicevox_wav_free