rarafy / OpenJTalkForUnity

A package for using OpenJTalk with Unity. It allows you to read out text.
MIT License
18 stars 2 forks source link
openjtalk unity unity3d-plugin unityplugin

OpenJTalk For Unity

A plug-in for using OpenJTalk on Unity.
It allows you to read out text dynamically.


Environment

The code is developed on following environments. Note that these are NOT minimum version requirements.


How to use

  1. Import OpenJTalkForUnity.unitypackage to your project
  1. Set "Edit > Project Settings > Other Settings > Configuration > Api Compatibility Level" to ".NET 4.x"

  2. Write the program. Refer to Assets\OpenJTalkForUnity\Scene.


When you want to use Package Manager

In "Window>Package Manager", select "Add package from git URL...". Then type https://github.com/rarafy/OpenJTalkForUnity.git?path=_Project/Packages/OpenJTalkForUnity and press "Add".

image

Let's also import the sample program. The sample programs will be placed in Assets/Samples/OpenJTalkForUnity/1.1.13/Sample.



API

There are several APIs available. Basically, you should refer to Assets\OpenJTalkForUnity\Scene to write scripts.


Q&A

It seems to be a problem with the unmanaged DLL. It does not interfere with actual use.
If you are really concerned about this, you can delete the corresponding file (some advanced features will not be available). e1


You can use any htsvoice that is placed in the hierarchy below Assets\OpenJTalkForUnity\dll\voice by specifying its name as the second argument of Speak().

Ex:When you want to use "takumi_happy.htsvoice"

void Start(){ OpenJTalkForUnity.Speak("Today is a nice day.", "takumi_happy"); }


A feature called Asynchronous (Task) can be used to solve this problem. For example

void Start()
{
  Task.Run(() => OpenJTalk.Speak("Today is a nice day."));
}

↑ Using tasks in this way will prevent the application from stopping while it is running.


You can unlock those parameters by editing Assets\OpenJTalkForUnity\Scripts\OpenJTalk.cs.
For example, if you want to add a Speed parameter, you can add tts.Speed = 1.0; to the line before tts.SpeakAsync(text);.
Of course, you can also rewrite the first part of the declaration as
JTalkTTS tts = new JTalkTTS { VoiceName = "tohoku-f01-neutral", Speed = 1.0 }.


References

jtalkdll(GitHub)