Skip to content

A package for using OpenJTalk with Unity. It allows you to read out text.

License

Notifications You must be signed in to change notification settings

rarafy/OpenJTalkForUnity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

  • Windows 10 20H2
  • Unity Editor 2020.3.12f1 (LTS)

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"

  1. 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.

  • OpenJTalk.VoiceTypeInfo() :Check which voices are available and output as Debug.Log.
  • OpenJTalk.SpeakRandomVoice(string text, double speed=1.0) :Speaks in a random voice.
  • OpenJTalk.Speak(string text = "Hello", string VoiceName = "tohoku-f01-neutral", double speed = 1.0) :Reads out an arbitrary string of text at a specified voice and speed.
  • OpenJTalk.SpeakRandomVoiceStoppable(string text = "Hello", double speed = 1.0) :It speaks in a random voice. (It's a Task, so it's asynchronous.)
  • OpenJTalk.SpeakStoppable(string text = "Hello", string VoiceName = "tohoku-f01-neutral", double speed = 1.0) :Reads out an arbitrary string of text at a specified voice and speed.
  • OpenJTalk.StopSpeaking() :Stop vocalizing midway.

Q&A

  • I'm getting a mysterious error.

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


  • I want to use a different voice.

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"); }


  • My app stops while reading out loud.

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.


  • Um, OpenJTalk, I think there were more parameters? (Advanced)

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)

About

A package for using OpenJTalk with Unity. It allows you to read out text.

Topics

Resources

License

Stars

Watchers

Forks

Languages