Female voice in Speak.js

2019-05-21 14:27发布

We are using speak.js library for Text to speech purpose. And we need to implement female voice with localization in this. We are calling its speak function as meSpeak.speak('Hello Thomas"); but we could not able to make it's op in female voice. We have observed that we need to pass some arg as parameter but not able to pass this too. Can you please guide how can i get female voice op using speak.js lib ?

Many thanks in Advance

1条回答
聊天终结者
2楼-- · 2019-05-21 15:17

Supposing you're talking about mespeak.js:

Download the latest version at http://www.masswerk.at/mespeak

Make a copy of a voice-file (json) in the language of choice and open it in an editor.

The voice-files are of the following structure:

{
  "voice_id": "<filename>",
  "dict_id":  "<filename>",
  "dict":     "<base64-encoded octet stream>",
  "voice":    "<base64-encoded octet stream>"
}

First, provide a unique "voice_id" (e.g. "en-us-f", the ids are actually unix-filenames).

The encoded voice data is actually a text-file to be found in eSpeak's data-directory (see http://espeak.sourceforge.net/). While the files are represented as base64-encoded octet-streams, you may also use a text-string for this by providing another property "voice_encoding":

{
  "voice_id": "<filename>",
  "dict_id":  "<filename>",
  "dict":     "<base64-encoded octet stream>",
  "voice":    "<text-string>",
  "voice_encoding": "text"
}

Now, referring to the eSpeak-data and the eSpeak-docs for voices, you may find the following text for the voice "en-us":

// moving towards US English
name english-us
language en-us 2
language en-r
language en 3
gender male
[and more]

by removing the comment in the first line, editing the name (we want this to be unique) and finally changing the gender, you'll arrive at:

name english-us-f
language en-us 2
language en-r
language en 3
gender female

Replace any line-breaks by "\n" to get a valid JSON-string:

"name english-us-f\nlanguage en-us 2\nlanguage en-r\nlanguage en 3\ngender female"

and use this as the value of the property "voice". Save your file and load it into meSpeak.

You may fine-tune the voice according to the eSpeak-Docs: http://espeak.sourceforge.net/voices.html

(An alternate way would involve saving a plain eSpeak-voice file and encoding its content as base64-string and using this as a value for "voice". In this case you would not set the "voice_encoding" property. Using plain-text might be more suitable for testing.)

Hope this helps (it won't get easier than this).

N.L.

Edit: Please mind that any malformed voice-string will cause an error in (m)eSpeak. (eSpeak is not gracious on syntax errors, but will throw a "type-error" – which is handled as a console-log by meSpeak. Keep in mind that the core of meSpeak is just an Emscripten-generated port of eSpeak. So it doesn't handle voice-files any better.)

Edit: An (extended) version of this is now part of the meSpeak-documentation: http://www.masswerk.at/mespeak/voices-and-languages.html

查看更多
登录 后发表回答