Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Voicevox Coreのラッパーライブラリ

License

NotificationsYou must be signed in to change notification settings

sh1ma/voicevoxcore.go

Repository files navigation

codecovCI: Testgolangci-lint

voicevoxcore.go はvoicevox_coreを Go 言語で使えるラッパーです。FFI を用いて、voicevox_core の C API を呼んでいます。

インストール

go get https://github.com/sh1ma/voicevoxcore.go

以下は本ライブラリを使用して Text to Speech を行う例です。

//go:build ignorepackage mainimport ("fmt""os"voicevoxcorego"github.com/sh1ma/voicevoxcore.go")funcmain() {text:="ずんだもんなのだ"core:=voicevoxcorego.NewVoicevoxCore()initializeOptions:=voicevoxcorego.NewVoicevoxInitializeOptions(0,0,false,"./open_jtalk_dic_utf_8-1.11")core.Initialize(initializeOptions)core.LoadModel(3)ttsOptions:=voicevoxcorego.NewVoicevoxTtsOptions(false,true)result,err:=core.Tts(text,1,ttsOptions)iferr!=nil {fmt.Println(err)}f,_:=os.Create("out.wav")_,err=f.Write(result)iferr!=nil {fmt.Println(err)}}

おすすめの環境構築方法 (Linux / MacOS)

本ライブラリを使用するには openJTalk の辞書ファイルと voicevox_core の動的ライブラリ、ヘッダファイル、そしてモデルファイルが必要になります。以下でそれらをダウンロードし、本ライブラリから使えるようにするための簡単なセットアップの手順を説明します。

1. voicevox_core のダウンロード

voicevox_core の releasesから自分の OS、アーキテクチャに合ったダウンローダをダウンロードし、実行してください。実行するとカレントディレクトリにvoicevox_core_*のディレクトリが配置されます。直下には以下のものが入っています

  • openJTalk の辞書ファイルが入ったopen_jtalk_dic_*/ディレクトリ
  • voicevox_core の動的ライブラリ
    • 拡張子は.dll, .dylib, .so のいずれかです
  • 圧縮されたモデルファイルの入ったmodel/ディレクトリ

2. voicevox_core を配置する

voicevox_coreを任意のパスに移動(おすすめは~/.localのなか)します

3. シンボリックリンクを張る

voicevox_core内にある 2 つのファイルのシンボリックリンクを作ります。以下のようなコマンドを実行します。(プラットフォームによってコマンドが異なる場合があります)。動的ライブラリが.dylibの場合を例に挙げます。

注意: ln に渡すパスは相対パスではなく絶対パスにしてください

# [VOICEVOX_CORE_DIR] を`voicevox_core`の絶対パスにします# 動的ライブラリのシンボリックリンクを`/usr/local/lib`に配置しますln -s [VOICEVOX_CORE_DIR]/libvoicevox_core.dylib /usr/local/lib# 動的ライブラリのシンボリックリンクを`/usr/local/include`に配置しますln -s [VOICEVOX_CORE_DIR]/voicevox_core.h /usr/local/include

以上の手順で本ライブラリが使えるようになっているはずです。

About

Voicevox Coreのラッパーライブラリ

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp