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

0.0.3 #2

Merged
merged 3 commits into from
Mar 5, 2024
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
15 changes: 11 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -52,8 +52,15 @@ jobs:

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -67,4 +74,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check w/o SNAPSHOT when "bump version"
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
run: grep "<version>" pom.xml | head -1 | grep -v SNAPSHOT

- name: Set up JDK 8
uses: actions/setup-java@v3
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '8'
java-version: '17'
distribution: 'temurin'
cache: maven

Expand Down
29 changes: 11 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[![Release](https://jitpack.io/v/umjammer/Gyutan.svg)](https://jitpack.io/#umjammer/Gyutan)
[![Java CI](https://github.com/umjammer/Gyutan/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/Gyutan/actions/workflows/maven.yml)
[![CodeQL](https://github.com/umjammer/Gyutan/actions/workflows/codeql.yml/badge.svg)](https://github.com/umjammer/Gyutan/actions/workflows/codeql.yml)
![Java](https://img.shields.io/badge/Java-8-b07219)
[![Parent](https://img.shields.io/badge/Parent-vavi--speech-pink)](https://github.com/umjammer/vavi-speech)
![Java](https://img.shields.io/badge/Java-17-b07219)
[![Parent](https://img.shields.io/badge/Parent-vavi--speech2-pink)](https://github.com/umjammer/vavi-speech2)

# Gyutan

<img src="https://user-images.githubusercontent.com/493908/213547722-3ee7bd92-9adb-415d-bac4-b318ec1174a7.png" width="160"/>
<img src="https://user-images.githubusercontent.com/493908/213547722-3ee7bd92-9adb-415d-bac4-b318ec1174a7.png" width="160" alt="Gyutan Image"/>

mavenized Gyutan
mavenized Gyutan (text -> label -> [sasakama](https://github.com/umjammer/Sasakama) -> speech)

## Install

Expand All @@ -19,31 +19,23 @@ mavenized Gyutan
```
* download HTS voice
```shell
$ cd $SRC_BASE
$ cd $RESOURCE_BASE
$ git clone https://github.com/icn-lab/htsvoice-tohoku-f01.git
```
* set "fn.voice" in local.properties
```shell
$ cd $SRC_BASE/Gyutan
$ vi local.properties
$ cat local.properties
fn.voice=/Users/nsano/src/java/htsvoice-tohoku-f01/tohoku-f01-neutral.htsvoice
```
* install sen
```shell
$ cd $SRC_BASE
$ git clone https://gitlab.com/umjammer/sen.git
$ cd $SRC_BASE/sen
$ export SEN_HOME=$SRC_BASE/sen/src/main/home
$ mvn install
fn.voice=/Users/foo/src/resources/htsvoice-tohoku-f01/tohoku-f01-neutral.htsvoice
```
* set "sen.home" in local.properties
```shell
$ cd $SRC_BASE/Gyutan
$ vi local.properties
$ cat local.properties
fn.voice=/Users/nsano/src/java/htsvoice-tohoku-f01/tohoku-f01-neutral.htsvoice
sen.home=/Users/nsano/src/java/sen/src/main/home
fn.voice=/Users/foo/src/resources/htsvoice-tohoku-f01/tohoku-f01-neutral.htsvoice
sen.home=/Users/foo/src/java/Gyutan/sen
```

## Usage
Expand All @@ -65,10 +57,11 @@ mavenized Gyutan

* make njd as user friendly library
* ~~mora_size == 0 -> no pronounce -> delete~~
* github ci needs to download and build dictionary
* ~~github ci needs to download and build dictionary~~

---
[Original](https://github.com/icn-lab/Gyutan)

# [Original](https://github.com/icn-lab/Gyutan)

Copyright (c) 2015-2016 Intelligent Communication Network (Ito-Nose) Laboratory Tohoku University.
Copyright (c) 2001-2016 Nagoya Institute of Technology Department of Computer Science.
Expand Down
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
21 changes: 12 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>icn-lab</groupId>
<artifactId>gyutan</artifactId>
<version>0.0.2</version>
<version>0.0.3</version>

<profiles>
<profile>
Expand All @@ -32,8 +32,13 @@
<arg line="-x ${sen.home}" />
<arg line="-m ${fn.voice}" />
<arg line="-ow ${wave}" />
<arg line="-g -20" />
<arg value="${text}" />
</java>
<exec executable="play" outputproperty="ignore">
<arg line="-v 1" />
<arg value="${wave}" />
</exec>
</target>
</configuration>
</plugin>
Expand Down Expand Up @@ -84,17 +89,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<version>3.2.2</version>
<configuration>
<argLine>
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
Expand Down Expand Up @@ -123,7 +126,7 @@
<url>https://jitpack.io</url>
</repository>
<repository>
<id>gitlab-maven</id>
<id>gitlab-maven</id> <!-- sen -->
<url>https://gitlab.com/api/v4/projects/18523814/packages/maven</url>
</repository>
</repositories>
Expand All @@ -133,7 +136,7 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.9.1</version>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -156,7 +159,7 @@
<dependency>
<groupId>com.github.umjammer</groupId>
<artifactId>vavi-commons</artifactId>
<version>1.1.8</version>
<version>1.1.10</version>
</dependency>

<dependency>
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/Gyutan.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

Expand Down Expand Up @@ -85,8 +86,6 @@ public static void usage() {
System.err.print(
" text file [stdin]\n");
System.err.print("\n");

System.exit(0);
}

public static void main(String[] args) {
Expand Down Expand Up @@ -120,12 +119,13 @@ else if (args[i].equals("-h"))
System.exit(1);
}


org.icn.gyutan.Gyutan gyutan = new org.icn.gyutan.Gyutan();
boolean flag = gyutan.initialize(dn_dict, fn_voice);
if (!flag) {
org.icn.gyutan.Gyutan gyutan = null;
try {
gyutan = new org.icn.gyutan.Gyutan(dn_dict, fn_voice);
} catch (IOException e) {
System.err.println("Error: initialize failed");
usage();
return;
}

String txtfn = null;
Expand Down Expand Up @@ -188,7 +188,7 @@ else if (args[cnt].startsWith("-")) {
byte[] buf = new byte[txtfp.available()];
txtfp.read(buf);
String text = new String(buf);
gyutan.synthesis(text, wavfp, logfp);
gyutan.synthesize(text, wavfp, logfp);

if (labelfp != null)
gyutan.save_label(labelfp);
Expand Down
49 changes: 19 additions & 30 deletions src/main/java/org/icn/gyutan/Gyutan.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
package org.icn.gyutan;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.logging.Level;

Expand Down Expand Up @@ -60,34 +61,25 @@ public class Gyutan {
private JPCommon jpcommon;
private Engine engine;

public boolean initialize(String confPath, String fn_voice) {
public Gyutan(String confPath, String fn_voice) throws IOException {
jpcommon = null;
njd = null;

// for Sen;
boolean flagSen = initializeSen(confPath);
initializeSen(confPath);

// for HTS_Engine;
boolean flagEngine = initializeEngine(fn_voice);

return flagSen && flagEngine;
initializeEngine(fn_voice);
}

public boolean initializeSen(String confPath) {
try {
sen = StringTagger.getInstance(confPath + "/conf/sen.xml");
// CompositPostProcessor cpp = new CompositPostProcessor();
// cpp.readRules(new BufferedReader(new StringReader("記号-アルファベット")));
// sen.addPostProcessor(cpp);
return true;
} catch (Exception e) {
e.printStackTrace();
sen = null;
return false;
}
private void initializeSen(String confPath) throws IOException {
sen = StringTagger.getInstance(confPath + "/conf/sen.xml");
// CompositPostProcessor cpp = new CompositPostProcessor();
// cpp.readRules(new BufferedReader(new StringReader("記号-アルファベット")));
// sen.addPostProcessor(cpp);
}

public boolean initializeEngine(String fn_voice) {
private void initializeEngine(String fn_voice) {
String[] fn_voices = new String[1];
fn_voices[0] = fn_voice;
engine = new Engine();
Expand All @@ -96,11 +88,8 @@ public boolean initializeEngine(String fn_voice) {
if (!engine.get_full_context_label_format().equals("HTS_TTS_JPN")) {
Debug.print(Level.SEVERE, "hts_voice is not support HTS_TTS_JPN");
engine.clear();
engine = null;
return false;
throw new IllegalArgumentException(engine.get_full_context_label_format());
}

return flag;
}

public boolean availableSen() {
Expand Down Expand Up @@ -210,29 +199,29 @@ public String[] get_label(boolean withTime) {
return jpcommon.label.get_feature();
}

public int synthesis(String text, FileOutputStream wavf, FileOutputStream logf) {
public int synthesize(String text, FileOutputStream wavf, FileOutputStream logf) {
if (!availableSen() || !availableEngine())
return -1;

String[] feature = analysis_text(text);
make_label(feature);

return synthesis(wavf, logf);
return synthesize(wavf, logf);
}

public int synthesis(String[] feature, FileOutputStream wavf, FileOutputStream logf) {
public int synthesize(String[] feature, FileOutputStream wavf, FileOutputStream logf) {
if (!availableEngine())
return -1;

make_label(feature);
return synthesis(wavf, logf);
return synthesize(wavf, logf);
}

public int synthesis(String text) {
return synthesis(text, null, null);
public int synthesize(String text) {
return synthesize(text, null, null);
}

public int synthesis(FileOutputStream wavf, FileOutputStream logf) {
public int synthesize(FileOutputStream wavf, FileOutputStream logf) {
long t1, t2;
if (jpcommon == null)
return -1;
Expand Down Expand Up @@ -356,7 +345,7 @@ public void make_label(String[] feature) {
// System.err.printf("++accent_analysis time[us]:%f\n", (t3 - t2) / 1e+03);
}

public String hankakuToZenkaku(String text) {
public static String hankakuToZenkaku(String text) {
StringBuilder sb = new StringBuilder(text);
for (int i = 0; i < sb.length(); i++) {
char c = sb.charAt(i);
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/org/icn/gyutan/NJD.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ public class NJD {

private int get_token_from_string(String str, int[] index, StringBuilder buff, char d) {
buff.delete(0, buff.length());
char[] charat = str.toCharArray();

if (index[0] == str.length())
return 0;

// char c = str.charAt(index[0]);
char c = charat[index[0]];
char c = str.charAt(index[0]);
if (c == d) {
index[0]++;
return 0;
Expand All @@ -75,17 +73,15 @@ private int get_token_from_string(String str, int[] index, StringBuilder buff, c
index[0]++;
if (index[0] == str.length())
return 0;
// c = str.charAt(index[0]);
c = charat[index[0]];
c = str.charAt(index[0]);
}

int i;
for (i = 0; c != d && c != '\n' && c != 'r' && c != '\t'; i++) {
buff.append(c);
index[0]++;
if (index[0] < str.length())
// c = str.charAt(index[0]);
c = charat[index[0]];
c = str.charAt(index[0]);
}
if (c == d)
index[0]++;
Expand Down Expand Up @@ -294,7 +290,7 @@ void push_node(NJDNode node) {
}

NJDNode remove_node(NJDNode node) {
NJDNode next = null;
NJDNode next;

if (node == head && node == tail) {
head = null;
Expand Down
Loading