Skip to content

Commit

Permalink
Merge pull request #18 from umjammer/0.0.15
Browse files Browse the repository at this point in the history
0.0.15
  • Loading branch information
umjammer authored Mar 26, 2024
2 parents 7e8d666 + 95fa9d5 commit 23fe344
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 23 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Text to Speech and Speech to Text (JSAPI2) engines for Java
* [download](https://voicevox.hiroshiba.jp/) the application
* run the application before using this library

### DoCoMo AI Agent API

* https://agentcraft.sebastien.ai/

## Usage

### user
Expand Down Expand Up @@ -83,5 +87,8 @@ Text to Speech and Speech to Text (JSAPI2) engines for Java
* [LMROID](https://lmroidsoftware.wixsite.com/nhoshio)
* [SHAREVOX](https://www.sharevox.app)
* [http://itvoice.starfree.jp/](http://itvoice.starfree.jp/)
* AVSpeechSynthesizer needs block
* AVSpeechSynthesizer needs [obj-c block](https://github.com/umjammer/rococoa/discussions/23)
* ~~rcp client/server (wip)~~ -> [vavi-speech-rpc](https://github.com/umjammer/vavi-speech-rpc)

---
<sub>images by <a href="https://commons.nicovideo.jp/works/nc327182">霊夢</a>, <a href="https://commons.nicovideo.jp/works/nc327184">魔理沙</a>, <a href="https://seiga.nicovideo.jp/seiga/im10865385">ずんだもん</a></sub>
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>vavi</groupId>
<artifactId>vavi-speech2</artifactId>
<version>0.0.14</version>
<version>0.0.15</version>

<name>vavi-speech2</name>
<description/>
Expand Down Expand Up @@ -216,13 +216,13 @@
<dependency>
<groupId>com.github.umjammer.rococoa</groupId> <!-- org.rococoa / com.github.umjammer.rococoa -->
<artifactId>rococoa-core</artifactId>
<version>0.8.7</version>
<version>0.8.11</version>
</dependency>

<dependency>
<groupId>com.github.umjammer</groupId> <!-- vavi / com.github.umjammer -->
<artifactId>vavi-speech</artifactId>
<version>0.1.10</version>
<version>0.1.11</version>
<exclusions>
<exclusion>
<groupId>javax.speech</groupId>
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/vavi/speech/BaseEnginFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import javax.speech.EngineList;
Expand Down Expand Up @@ -124,7 +125,14 @@ protected EngineList createEngineListForSynthesizer(EngineMode require) {
logger.log(Level.TRACE, getClass().getSimpleName() + " --------");

// get all voices available
List<WrappedVoice<V>> voices = geAlltVoices();
List<WrappedVoice<V>> voices = null;
try {
voices = geAlltVoices();
} catch (Throwable t) {
logger.log(Level.WARNING, t.getMessage(), t);
}
if (voices == null)
voices = Collections.emptyList();
logger.log(Level.TRACE, "voices: " + voices.size());

// We want to get all combinations of domains and locales
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public AquesTalk10SynthesizerMode(String engineName,
Boolean supportsLetterToSound,
Boolean supportsMarkup,
Voice[] voices) {
super(engineName, modeName, running, supportsLetterToSound, false, voices);
super(engineName, modeName, running, supportsLetterToSound, supportsMarkup, voices);
}

@Override
Expand Down
23 changes: 18 additions & 5 deletions src/main/java/vavi/speech/aquestalk10/jsapi2/AquesTalk10Voice.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@

package vavi.speech.aquestalk10.jsapi2;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import javax.speech.SpeechLocale;
import javax.speech.synthesis.Voice;

import vavi.speech.WrappedVoice;
import vavi.speech.aquestalk10.jna.AquesTalk10.AQTK_VOICE;
import vavi.speech.aquestalk10.jna.AquesTalk10Wrapper;
import vavi.util.Debug;


/**
Expand Down Expand Up @@ -51,12 +54,22 @@ public List<AQTK_VOICE> getAllNativeVoices() {

@Override
public List<WrappedVoice<AQTK_VOICE>> getAllVoices() {
List<WrappedVoice<AQTK_VOICE>> voices = new LinkedList<>();
for (Map.Entry<String, AQTK_VOICE> nativeVoice : AquesTalk10Wrapper.voices.entrySet()) {
WrappedVoice<AQTK_VOICE> voice = new AquesTalk10Voice(nativeVoice);
voices.add(voice);
try {
List<WrappedVoice<AQTK_VOICE>> voices = new LinkedList<>();
for (Map.Entry<String, AQTK_VOICE> nativeVoice : AquesTalk10Wrapper.voices.entrySet()) {
WrappedVoice<AQTK_VOICE> voice = new AquesTalk10Voice(nativeVoice);
voices.add(voice);
}
return voices;
} catch (UnsatisfiedLinkError e) {
if (System.getProperty("os.arch").equals("aarch64")) {
Debug.println(Level.WARNING, "AquesTalk10 doesn't support arm64 architecture.");
} else {
Debug.println(Level.SEVERE, "install AquesTalk10 and locate frameworks at proper directory.");
}
Debug.printStackTrace(Level.FINEST, e);
return Collections.emptyList();
}
return voices;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public EngineList createEngineList(EngineMode require) {
protected List<WrappedVoice<com.google.cloud.texttospeech.v1.Voice>> geAlltVoices() {
try {
return GoogleCloudTextToSpeechVoice.factory.getAllVoices();
} catch (IllegalStateException e) {
logger.log(Level.WARNING, e.getMessage());
} catch (Throwable t) {
logger.log(Level.WARNING, t.getMessage() + " env: " + System.getenv("GOOGLE_APPLICATION_CREDENTIALS"), t);
return Collections.emptyList();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public GoogleCloudTextToSpeechSynthesizerMode(String engineName,
Boolean supportsLetterToSound,
Boolean supportsMarkup,
Voice[] voices) {
super(engineName, modeName, running, supportsLetterToSound, false, voices);
super(engineName, modeName, running, supportsLetterToSound, supportsMarkup, voices);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected GoogleCloudTextToSpeechVoice(com.google.cloud.texttospeech.v1.Voice na
nativeVoice);
}

/** @throws IllegalStateException credentials are not set */
@Override
public List<com.google.cloud.texttospeech.v1.Voice> getAllNativeVoices() {
try (TextToSpeechClient textToSpeechClient = TextToSpeechClient.create()) {
Expand All @@ -62,6 +63,7 @@ public List<com.google.cloud.texttospeech.v1.Voice> getAllNativeVoices() {
}
}

/** @throws IllegalStateException credentials are not set */
@Override
public List<WrappedVoice<com.google.cloud.texttospeech.v1.Voice>> getAllVoices() {
List<WrappedVoice<com.google.cloud.texttospeech.v1.Voice>> voiceList = new LinkedList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public GyutanSynthesizerMode(String engineName,
Boolean supportsLetterToSound,
Boolean supportsMarkup,
Voice[] voices) {
super(engineName, modeName, running, supportsLetterToSound, false, voices);
super(engineName, modeName, running, supportsLetterToSound, supportsMarkup, voices);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public OpenJTalkSynthesizerMode(String engineName,
Boolean supportsLetterToSound,
Boolean supportsMarkup,
Voice[] voices) {
super(engineName, modeName, running, supportsLetterToSound, false, voices);
super(engineName, modeName, running, supportsLetterToSound, supportsMarkup, voices);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

package vavi.speech.rococoa.jsapi2;

import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.Collections;
import java.util.List;
import javax.speech.EngineList;
import javax.speech.EngineMode;
Expand All @@ -17,6 +20,8 @@
import vavi.speech.WrappedVoice;
import vavix.rococoa.avfoundation.AVSpeechSynthesisVoice;

import static java.lang.System.getLogger;


/**
* Factory for the Mac Speech engine.
Expand All @@ -26,14 +31,25 @@
*/
public class RococoaEngineListFactory extends BaseEnginFactory<AVSpeechSynthesisVoice> implements EngineListFactory {

private static final Logger logger = getLogger(RococoaEngineListFactory.class.getName());

@Override
public EngineList createEngineList(EngineMode require) {
return createEngineListForSynthesizer(require);
}

@Override
protected List<WrappedVoice<AVSpeechSynthesisVoice>> geAlltVoices() {
return RococoaVoice.factory.getAllVoices();
try {
List<WrappedVoice<AVSpeechSynthesisVoice>> voices = RococoaVoice.factory.getAllVoices();
if (voices != null) {
return voices;
}
logger.log(Level.WARNING, "voices are null, something is wrong");
} catch (Throwable t) {
logger.log(Level.WARNING, t.getMessage());
}
return Collections.emptyList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public RococoaSynthesizerMode(String engineName,
Boolean supportsLetterToSound,
Boolean supportsMarkup,
Voice[] voices) {
super(engineName, modeName, running, supportsLetterToSound, false, voices);
super(engineName, modeName, running, supportsLetterToSound, supportsMarkup, voices);
}

@Override
Expand Down
20 changes: 16 additions & 4 deletions src/main/java/vavi/speech/voicevox/VoiceVox.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,31 @@ public static class Mora{
}
/** @param speed default: 1, range: 0.50 ~ 2.00 */
public void setSpeed(float speed) {
speedScale = speed;
if (0.5 <= speed && speed <= 2.0)
speedScale = speed;
else
speedScale = 1;
}
/** @param pitch default: 0, range: -0.15 ~ 0.15 */
public void setPitch(float pitch) {
pitchScale = pitch;
if (-0.15 <= pitch && pitch <= 0.15)
pitchScale = pitch;
else
pitchScale = 0;
}
/** @param intonation range: 0 ~ 2 */
public void setIntonation(float intonation) {
intonationScale = intonation;
if (0 <= intonation && intonation <= 2)
intonationScale = intonation;
else
intonationScale = 1;
}
/** @param volume default: 1, range: 0.50 ~ 2.00 */
public void setVolume(float volume) {
volumeScale = volume;
if (0.5 <= volume && volume <= 2.0)
volumeScale = volume;
else
volumeScale = 1;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public VoiceVoxSynthesizerMode(String engineName,
Boolean supportsLetterToSound,
Boolean supportsMarkup,
Voice[] voices) {
super(engineName, modeName, running, supportsLetterToSound, false, voices);
super(engineName, modeName, running, supportsLetterToSound, supportsMarkup, voices);
}

@Override
Expand Down

0 comments on commit 23fe344

Please sign in to comment.