-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ae1110
commit 4c4b767
Showing
19 changed files
with
791 additions
and
1 deletion.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/GlobalInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package jp.hiroshiba.voicevoxcore; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.annotations.Expose; | ||
import com.google.gson.annotations.SerializedName; | ||
import jakarta.annotation.Nonnull; | ||
|
||
/** VOICEVOX CORE自体の情報。 */ | ||
public class GlobalInfo extends Dll { | ||
/** | ||
* ライブラリのバージョン。 | ||
* | ||
* @return ライブラリのバージョン。 | ||
*/ | ||
@Nonnull | ||
public static String getVersion() { | ||
return rsGetVersion(); | ||
} | ||
|
||
/** | ||
* このライブラリで利用可能なデバイスの情報を取得する。 | ||
* | ||
* @return {@link SupportedDevices}。 | ||
*/ | ||
@Nonnull | ||
public static SupportedDevices getSupportedDevices() { | ||
Gson gson = new Gson(); | ||
String supportedDevicesJson = rsGetSupportedDevicesJson(); | ||
SupportedDevices supportedDevices = gson.fromJson(supportedDevicesJson, SupportedDevices.class); | ||
if (supportedDevices == null) { | ||
throw new NullPointerException("supported_devices"); | ||
} | ||
return supportedDevices; | ||
} | ||
|
||
@Nonnull | ||
private static native String rsGetVersion(); | ||
|
||
@Nonnull | ||
private static native String rsGetSupportedDevicesJson(); | ||
|
||
/** | ||
* このライブラリで利用可能なデバイスの情報。 | ||
* | ||
* <p>あくまで本ライブラリが対応しているデバイスの情報であることに注意。GPUが使える環境ではなかったとしても {@link #cuda} や {@link #dml} は {@code | ||
* true} を示しうる。 | ||
*/ | ||
public static class SupportedDevices { | ||
/** | ||
* CPUが利用可能。 | ||
* | ||
* <p>常に <code>true</code> 。 | ||
*/ | ||
@SerializedName("cpu") | ||
@Expose | ||
@Nonnull | ||
public final boolean cpu; | ||
|
||
/** | ||
* CUDAが利用可能。 | ||
* | ||
* <p>ONNX Runtimeの <a href= | ||
* "https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html" | ||
* target="_blank">CUDAExecutionProvider</a>に対応する。 必要な環境についてはそちらを参照。 | ||
*/ | ||
@SerializedName("cuda") | ||
@Expose | ||
@Nonnull | ||
public final boolean cuda; | ||
|
||
/** | ||
* DirectMLが利用可能。 | ||
* | ||
* <p>ONNX Runtimeの <a href= | ||
* "https://onnxruntime.ai/docs/execution-providers/DirectML-ExecutionProvider.html" | ||
* target="_blank">DmlExecutionProvider</a>に対応する。 必要な環境についてはそちらを参照。 | ||
*/ | ||
@SerializedName("dml") | ||
@Expose | ||
@Nonnull | ||
public final boolean dml; | ||
|
||
private SupportedDevices() { | ||
this.cpu = false; | ||
this.cuda = false; | ||
this.dml = false; | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
crates/voicevox_core_java_api/lib/src/main/java/jp/hiroshiba/voicevoxcore/OpenJtalk.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
crates/voicevox_core_java_api/lib/src/test/java/jp/hiroshiba/voicevoxcore/InfoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* GlobalInfoのテスト。 | ||
*/ | ||
package jp.hiroshiba.voicevoxcore; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class InfoTest { | ||
@Test | ||
void checkVersion() { | ||
assertNotNull(GlobalInfo.getVersion()); | ||
} | ||
|
||
@Test | ||
void checkSupportedDevices() { | ||
GlobalInfo.SupportedDevices supportedDevices = GlobalInfo.getSupportedDevices(); | ||
|
||
assertNotNull(supportedDevices); | ||
assertTrue(supportedDevices.cpu); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::common::throw_if_err; | ||
use jni::{sys::jobject, JNIEnv}; | ||
#[no_mangle] | ||
extern "system" fn Java_jp_hiroshiba_voicevoxcore_GlobalInfo_rsGetVersion( | ||
env: JNIEnv<'_>, | ||
) -> jobject { | ||
throw_if_err(env, std::ptr::null_mut(), |env| { | ||
let version = env.new_string(env!("CARGO_PKG_VERSION"))?; | ||
Ok(version.into_raw()) | ||
}) | ||
} | ||
#[no_mangle] | ||
extern "system" fn Java_jp_hiroshiba_voicevoxcore_GlobalInfo_rsGetSupportedDevicesJson( | ||
env: JNIEnv<'_>, | ||
) -> jobject { | ||
throw_if_err(env, std::ptr::null_mut(), |env| { | ||
let supported_devices = voicevox_core::SupportedDevices::create()?; | ||
let json = serde_json::to_string(&supported_devices).expect("Should not fail"); | ||
let json = env.new_string(json)?; | ||
Ok(json.into_raw()) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod common; | ||
mod info; | ||
mod open_jtalk; | ||
mod synthesizer; | ||
mod user_dict; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# Linux start script should use lf | ||
./gradlew text eol=lf linguist-vendored linguist-generated | ||
|
||
# These are Windows script files and should use crlf | ||
*.bat text eol=crlf | ||
|
||
./gradlew linguist-vendored linguist-generated | ||
./gradlew.bat linguist-vendored linguist-generated | ||
./gradle/wrapper/gradle-wrapper.jar linguist-vendored linguist-generated |
Oops, something went wrong.