
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
フリーの日本語音声合成エンジン OpenJTalk を利用する Node.js モジュールです。
$ npm install openjtalk
$ npm test
もっともシンプルなコードは以下になります。
var OpenJTalk = require('openjtalk');
var mei = new OpenJTalk();
mei.talk('こんにちは世界');
.htsvoice
のパスと辞書ファイルを含んだディレクトリ、OpenJTalk の設定オプションを引数に渡せます。
引数は省略することもできます。省略した場合は MMDAgent のメイちゃんの声をデフォルトとして喋ります。
音声ファイルを複数用意すれば以下のように喋り分け出来ます。
var OpenJTalk = require('openjtalk');
var mei1 = new OpenJTalk(); // mei_normal を使用
var mei2 = new OpenJTalk({ htsvoice: './voice/mei/mei_angry.htsvoice' });
var mei3 = new OpenJTalk({ htsvoice: './voice/mei/mei_happy.htsvoice' });
mei1.talk('これはテストです'); // コールバックは省略できる
setTimeout(function() {
mei2.talk('喋り終わり次第コールバックを呼びます', function(err) {
if (err) console.log('err', err);
console.log('コールバックを呼ぶ');
mei3.talk('エラーが発生したらコールバックの引数からチェックできます', function(err) {
if (err) console.log('err', err);
else mei1.talk('エラーは発生しませんでした');
});
});
}, 2000);
設定値を変える場合は以下のようにします。
var OpenJTalk = require('./openjtalk');
var mei = new OpenJTalk({
htsvoice : './voice/mei/mei_normal.htsvoice',
dic : './dic/open_jtalk_dic_utf_8-1.08',
sampling_rate : 48000,
pitch : 220,
audio_buff_size : 48000,
alpha : 0.5,
beta : 0.8,
uv_threshold : 0.5,
gv_weight_mgc : 1.0,
gv_weight_lf0 : 1.0
});
// 喋る速度を調整することもできます
mei.talk('すっごい速いです', 100, function(err) {
mei.talk('普通くらいです', 200, function(err) {
mei.talk('ゆっくり喋るよ', 300);
});
});
上記がデフォルト値になります。
処理的には、OpenJTalk で wav を生成、それを afplay / aplay で再生、喋り終わったら削除、としているので、しゃべっている途中に中断すると wav ファイルが実行しているディレクトリに残ります。その際は手動で削除して下さい。
その他詳細は Twitter:@hecomi へご質問いただくか、http://tips.hecomi.com/ をご参照下さい。
FAQs
TTS using OpenJTalk
The npm package openjtalk receives a total of 6 weekly downloads. As such, openjtalk popularity was classified as not popular.
We found that openjtalk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.