Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change!(java): blockingパッケージを作ってクラス移動 #861

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package jp.hiroshiba.voicevoxcore;

/** ハードウェアアクセラレーションモード。 */
public enum AccelerationMode {
/** 実行環境に合わせて自動的に選択する。 */
AUTO,
/** CPUに設定する。 */
CPU,
/** GPUに設定する。 */
GPU,
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public class AudioQuery {
/**
* [読み取り専用] AquesTalk風記法。
*
* <p>{@link Synthesizer#createAudioQuery} が返すもののみ String となる。入力としてのAudioQueryでは無視される。
* <p>{@link jp.hiroshiba.voicevoxcore.blocking.Synthesizer#createAudioQuery} が返すもののみ String
* となる。入力としてのAudioQueryでは無視される。
*/
@SerializedName("kana")
@Expose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import jakarta.annotation.Nonnull;
import jp.hiroshiba.voicevoxcore.internal.Dll;

/** VOICEVOX CORE自体の情報。 */
public class GlobalInfo extends Dll {
public class GlobalInfo {
static {
Dll.loadLibrary();
}

/**
* ライブラリのバージョン。
*
Expand All @@ -19,6 +24,7 @@ public static String getVersion() {
@Nonnull
private static native String rsGetVersion();

// FIXME: dead code
@Nonnull
private static native String rsGetSupportedDevicesJson();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package jp.hiroshiba.voicevoxcore;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

/** 話者(speaker)のメタ情報。 */
public class SpeakerMeta {
/** 話者名。 */
@SerializedName("name")
@Expose
@Nonnull
public final String name;

/** 話者に属するスタイル。 */
@SerializedName("styles")
@Expose
@Nonnull
public final StyleMeta[] styles;

/** 話者のUUID。 */
@SerializedName("speaker_uuid")
@Expose
@Nonnull
public final String speakerUuid;

/** 話者のバージョン。 */
@SerializedName("version")
@Expose
@Nonnull
public final String version;

/**
* 話者の順番。
*
* <p>{@code SpeakerMeta}の列は、この値に対して昇順に並んでいるべきである。
*/
@SerializedName("order")
@Expose
@Nullable
public final Integer order;

private SpeakerMeta() {
// GSONからコンストラクトするため、このメソッドは呼ばれることは無い。
// このメソッドは@Nonnullを満たすために必要。
this.name = "";
this.styles = new StyleMeta[0];
this.speakerUuid = "";
this.version = "";
this.order = null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package jp.hiroshiba.voicevoxcore;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

/** スタイル(style)のメタ情報。 */
public class StyleMeta {
/** スタイル名。 */
@SerializedName("name")
@Expose
@Nonnull
public final String name;

/** スタイルID。 */
@SerializedName("id")
@Expose
public final int id;

/** スタイルに対応するモデルの種類。 */
@SerializedName("type")
@Expose
@Nonnull
public final StyleType type;

/**
* 話者の順番。
*
* <p>{@link SpeakerMeta#styles}の列は、この値に対して昇順に並んでいるべきである。
*/
@SerializedName("order")
@Expose
@Nullable
public final Integer order;

private StyleMeta() {
this.name = "";
this.id = 0;
this.type = StyleType.TALK;
this.order = null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package jp.hiroshiba.voicevoxcore;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/** スタイル(style)に対応するモデルの種類。 */
public enum StyleType {
/** 音声合成クエリの作成と音声合成が可能。 */
@SerializedName("talk")
@Expose
TALK,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package jp.hiroshiba.voicevoxcore;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import jakarta.annotation.Nonnull;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;

/** ユーザー辞書の単語。 */
public class UserDictWord {
/** 単語の表層形。 */
@SerializedName("surface")
@Expose
@Nonnull
public String surface;

/** 単語の発音。 発音として有効なカタカナである必要がある。 */
@SerializedName("pronunciation")
@Expose
@Nonnull
public String pronunciation;

/**
* 単語の種類。
*
* @see Type
*/
@SerializedName("word_type")
@Expose
@Nonnull
public Type wordType;

/** アクセント型。 音が下がる場所を指す。 */
@SerializedName("accent_type")
@Expose
public int accentType;

/** 単語の優先度。 0から10までの整数。 数字が大きいほど優先度が高くなる。 1から9までの値を指定することを推奨。 */
@SerializedName("priority")
@Expose
@Min(0)
@Max(10)
public int priority;

/**
* {@link UserDictWord}を作成する。
*
* @param surface 言葉の表層形。
* @param pronunciation 言葉の発音。
* @throws IllegalArgumentException pronunciationが不正な場合。
*/
public UserDictWord(String surface, String pronunciation) {
if (surface == null) {
throw new NullPointerException("surface");
}
if (pronunciation == null) {
throw new NullPointerException("pronunciation");
}

this.surface = rsToZenkaku(surface);
rsValidatePronunciation(pronunciation);
this.pronunciation = pronunciation;
this.wordType = Type.COMMON_NOUN;
this.accentType = 0;
this.priority = 5;
}

/**
* 単語の種類を設定する。
*
* @param wordType 単語の種類。
* @return このインスタンス。
*/
public UserDictWord wordType(Type wordType) {
if (wordType == null) {
throw new NullPointerException("wordType");
}
this.wordType = wordType;
return this;
}

/**
* アクセント型を設定する。
*
* @param accentType アクセント型。
* @return このインスタンス。
*/
public UserDictWord accentType(int accentType) {
if (accentType < 0) {
throw new IllegalArgumentException("accentType");
}
this.accentType = accentType;
return this;
}

/**
* 優先度を設定する。
*
* @param priority 優先度。
* @return このインスタンス。
* @throws IllegalArgumentException priorityが0未満または10より大きい場合。
*/
public UserDictWord priority(int priority) {
if (priority < 0 || priority > 10) {
throw new IllegalArgumentException("priority");
}
this.priority = priority;
return this;
}

@Nonnull
private static native String rsToZenkaku(String surface);

private static native void rsValidatePronunciation(String pronunciation);

/** 単語の種類。 */
public static enum Type {
/** 固有名詞。 */
@SerializedName("PROPER_NOUN")
@Expose
PROPER_NOUN,

/** 一般名詞。 */
@SerializedName("COMMON_NOUN")
@Expose
COMMON_NOUN,

/** 動詞。 */
@SerializedName("VERB")
@Expose
VERB,

/** 形容詞。 */
@SerializedName("ADJECTIVE")
@Expose
ADJECTIVE,

/** 語尾。 */
@SerializedName("SUFFIX")
@Expose
SUFFIX,
}
}
Loading
Loading