forked from VOICEVOX/voicevox_core
-
Notifications
You must be signed in to change notification settings - Fork 2
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
a6fb4ae
commit 300dd30
Showing
10 changed files
with
508 additions
and
0 deletions.
There are no files selected for viewing
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,9 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# Linux start script should use lf | ||
/gradlew text eol=lf | ||
|
||
# These are Windows script files and should use crlf | ||
*.bat text eol=crlf | ||
|
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,6 @@ | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build | ||
output.wav |
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,59 @@ | ||
/* | ||
* This file was generated by the Gradle 'init' task. | ||
* | ||
* This generated file contains a sample Kotlin application project to get you started. | ||
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.2.1/userguide/building_java_projects.html in the Gradle documentation. | ||
*/ | ||
|
||
plugins { | ||
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin. | ||
id 'org.jetbrains.kotlin.jvm' version '1.8.20' | ||
|
||
// Apply the application plugin to add support for building a CLI application in Java. | ||
id 'application' | ||
} | ||
|
||
repositories { | ||
// Use Maven Central for resolving dependencies. | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
// Use the Kotlin JUnit 5 integration. | ||
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5' | ||
|
||
// Use the JUnit 5 integration. | ||
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.2' | ||
|
||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
|
||
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.6") | ||
|
||
// TODO: ちゃんと配布したらそれに置き換える | ||
implementation files("../../../crates/voicevox_core_java_api/lib/build/libs/lib-0.0.0.jar") | ||
// https://mvnrepository.com/artifact/com.google.code.gson/gson | ||
implementation group: 'com.google.code.gson', name: 'gson', version: "2.10.1" | ||
// https://mvnrepository.com/artifact/jakarta.validation/jakarta.validation-api | ||
implementation group: 'jakarta.validation', name: 'jakarta.validation-api', version: "3.0.2" | ||
// https://mvnrepository.com/artifact/jakarta.annotation/jakarta.annotation-api | ||
implementation group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: "2.1.1" | ||
implementation group: 'com.microsoft.onnxruntime', name: 'onnxruntime', version: "1.14.0" | ||
} | ||
|
||
// Apply a specific Java toolchain to ease working on different environments. | ||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(11) | ||
} | ||
} | ||
|
||
application { | ||
// Define the main class for the application. | ||
mainClass = 'jp.hiroshiba.voicevoxcoreexample.AppKt' | ||
tasks.run.workingDir = rootProject.projectDir | ||
} | ||
|
||
tasks.named('test') { | ||
// Use JUnit Platform for unit tests. | ||
useJUnitPlatform() | ||
} |
59 changes: 59 additions & 0 deletions
59
example/java/app/src/main/kotlin/jp/hiroshiba/voicevoxcoreexample/App.kt
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,59 @@ | ||
/* | ||
* This Kotlin source file was generated by the Gradle 'init' task. | ||
*/ | ||
package jp.hiroshiba.voicevoxcoreexample | ||
|
||
import java.io.File | ||
import jp.hiroshiba.voicevoxcore.* | ||
import kotlinx.cli.* | ||
|
||
enum class Mode { | ||
AUTO, | ||
CPU, | ||
GPU | ||
} | ||
|
||
fun main(args: Array<String>) { | ||
val parser = ArgParser("example") | ||
val mode by parser.option(ArgType.Choice<Mode>(), description = "モード").default(Mode.AUTO) | ||
val vvmPath by | ||
parser.option(ArgType.String, fullName = "vvm", description = "vvmファイルへのパス").required() | ||
val dictDir by | ||
parser | ||
.option(ArgType.String, description = "Open JTalkの辞書ディレクトリ") | ||
.default("./open_jtalk_dic_utf_8-1.11") | ||
val text by | ||
parser | ||
.option(ArgType.String, description = "読み上げさせたい文章") | ||
.default("この音声は、ボイスボックスを使用して、出力されています。") | ||
val out by parser.option(ArgType.String, description = "出力wavファイルのパス").default("./output.wav") | ||
val styleId by parser.option(ArgType.Int, description = "話者IDを指定").default(0) | ||
|
||
parser.parse(args) | ||
|
||
println("Inititalizing: ${mode}, ${dictDir}") | ||
val openJtalk = OpenJtalk(dictDir) | ||
val synthesizer = | ||
Synthesizer.builder(openJtalk) | ||
.accelerationMode( | ||
when (mode) { | ||
Mode.AUTO -> Synthesizer.AccelerationMode.AUTO | ||
Mode.CPU -> Synthesizer.AccelerationMode.CPU | ||
Mode.GPU -> Synthesizer.AccelerationMode.GPU | ||
} | ||
) | ||
.build() | ||
|
||
println("Loading: ${vvmPath}") | ||
val vvm = VoiceModel(vvmPath) | ||
synthesizer.loadVoiceModel(vvm) | ||
|
||
println("Creating an AudioQuery from the text: ${text}") | ||
val audioQuery = synthesizer.createAudioQuery(text, styleId) | ||
|
||
println("Synthesizing... ${audioQuery}") | ||
val audio = synthesizer.synthesis(audioQuery, styleId).execute() | ||
|
||
println("Saving the audio to ${out}") | ||
File(out).writeBytes(audio) | ||
} |
14 changes: 14 additions & 0 deletions
14
example/java/app/src/test/kotlin/jp/hiroshiba/voicevoxcoreexample/AppTest.kt
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,14 @@ | ||
/* | ||
* This Kotlin source file was generated by the Gradle 'init' task. | ||
*/ | ||
package jp.hiroshiba.voicevoxcoreexample | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertNotNull | ||
|
||
class AppTest { | ||
@Test fun appHasAGreeting() { | ||
val classUnderTest = App() | ||
assertNotNull(classUnderTest.greeting, "app should have a greeting") | ||
} | ||
} |
Binary file not shown.
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,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.