-
Notifications
You must be signed in to change notification settings - Fork 131
Node.js向けのFFIを実装 #758
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
base: main
Are you sure you want to change the base?
Node.js向けのFFIを実装 #758
Changes from all commits
a12e6d2
7f871a3
ea809fb
a507b62
a3584d3
c418030
cd04f47
8a2462f
58ef4bb
04eee9a
2386695
e1fe417
bc6360f
cfd1c71
020e0dd
4dd1052
17a572f
e8e16dd
de13bf5
0f10872
c3eac14
b4e1251
3a63e2a
eda6086
8c7203f
0988e9f
dac865a
230da3e
1abc435
023a5d3
e98b733
4eef4f1
0b7890f
c9445e3
156dfb1
4906eac
ed215a7
427661d
a2a2251
15e7cbe
c5c52ea
950a7b3
7d45fda
d6fcae9
14e6e3d
55e6e00
6d6e619
48f3bb6
8ffbc91
72af516
046618b
e04da34
d97ecc7
aaefb43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [target.aarch64-unknown-linux-musl] | ||
| linker = "aarch64-linux-musl-gcc" | ||
| rustflags = ["-C", "target-feature=-crt-static"] | ||
| [target.x86_64-pc-windows-msvc] | ||
| rustflags = ["-C", "target-feature=+crt-static"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| # Created by https://www.toptal.com/developers/gitignore/api/node | ||
| # Edit at https://www.toptal.com/developers/gitignore?templates=node | ||
|
|
||
| ### Node ### | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| lerna-debug.log* | ||
|
|
||
| # Diagnostic reports (https://nodejs.org/api/report.html) | ||
| report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
|
||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
|
|
||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||
| lib-cov | ||
|
|
||
| # Coverage directory used by tools like istanbul | ||
| coverage | ||
| *.lcov | ||
|
|
||
| # nyc test coverage | ||
| .nyc_output | ||
|
|
||
| # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
| .grunt | ||
|
|
||
| # Bower dependency directory (https://bower.io/) | ||
| bower_components | ||
|
|
||
| # node-waf configuration | ||
| .lock-wscript | ||
|
|
||
| # Compiled binary addons (https://nodejs.org/api/addons.html) | ||
| build/Release | ||
|
|
||
| # Dependency directories | ||
| node_modules/ | ||
| jspm_packages/ | ||
|
|
||
| # TypeScript v1 declaration files | ||
| typings/ | ||
|
|
||
| # TypeScript cache | ||
| *.tsbuildinfo | ||
|
|
||
| # Optional npm cache directory | ||
| .npm | ||
|
|
||
| # Optional eslint cache | ||
| .eslintcache | ||
|
|
||
| # Microbundle cache | ||
| .rpt2_cache/ | ||
| .rts2_cache_cjs/ | ||
| .rts2_cache_es/ | ||
| .rts2_cache_umd/ | ||
|
|
||
| # Optional REPL history | ||
| .node_repl_history | ||
|
|
||
| # Output of 'npm pack' | ||
| *.tgz | ||
|
|
||
| # Yarn Integrity file | ||
| .yarn-integrity | ||
|
|
||
| # dotenv environment variables file | ||
| .env | ||
| .env.test | ||
|
|
||
| # parcel-bundler cache (https://parceljs.org/) | ||
| .cache | ||
|
|
||
| # Next.js build output | ||
| .next | ||
|
|
||
| # Nuxt.js build / generate output | ||
| .nuxt | ||
| dist | ||
|
|
||
| # Gatsby files | ||
| .cache/ | ||
| # Comment in the public line in if your project uses Gatsby and not Next.js | ||
| # https://nextjs.org/blog/next-9-1#public-directory-support | ||
| # public | ||
|
|
||
| # vuepress build output | ||
| .vuepress/dist | ||
|
|
||
| # Serverless directories | ||
| .serverless/ | ||
|
|
||
| # FuseBox cache | ||
| .fusebox/ | ||
|
|
||
| # DynamoDB Local files | ||
| .dynamodb/ | ||
|
|
||
| # TernJS port file | ||
| .tern-port | ||
|
|
||
| # Stores VSCode versions used for testing VSCode extensions | ||
| .vscode-test | ||
|
|
||
| # End of https://www.toptal.com/developers/gitignore/api/node | ||
|
|
||
| # Created by https://www.toptal.com/developers/gitignore/api/macos | ||
| # Edit at https://www.toptal.com/developers/gitignore?templates=macos | ||
|
|
||
| ### macOS ### | ||
| # General | ||
| .DS_Store | ||
| .AppleDouble | ||
| .LSOverride | ||
|
|
||
| # Icon must end with two | ||
| Icon | ||
|
|
||
|
|
||
| # Thumbnails | ||
| ._* | ||
|
|
||
| # Files that might appear in the root of a volume | ||
| .DocumentRevisions-V100 | ||
| .fseventsd | ||
| .Spotlight-V100 | ||
| .TemporaryItems | ||
| .Trashes | ||
| .VolumeIcon.icns | ||
| .com.apple.timemachine.donotpresent | ||
|
|
||
| # Directories potentially created on remote AFP share | ||
| .AppleDB | ||
| .AppleDesktop | ||
| Network Trash Folder | ||
| Temporary Items | ||
| .apdisk | ||
|
|
||
| ### macOS Patch ### | ||
| # iCloud generated files | ||
| *.icloud | ||
|
|
||
| # End of https://www.toptal.com/developers/gitignore/api/macos | ||
|
|
||
| # Created by https://www.toptal.com/developers/gitignore/api/windows | ||
| # Edit at https://www.toptal.com/developers/gitignore?templates=windows | ||
|
|
||
| ### Windows ### | ||
| # Windows thumbnail cache files | ||
| Thumbs.db | ||
| Thumbs.db:encryptable | ||
| ehthumbs.db | ||
| ehthumbs_vista.db | ||
|
|
||
| # Dump file | ||
| *.stackdump | ||
|
|
||
| # Folder config file | ||
| [Dd]esktop.ini | ||
|
|
||
| # Recycle Bin used on file shares | ||
| $RECYCLE.BIN/ | ||
|
|
||
| # Windows Installer files | ||
| *.cab | ||
| *.msi | ||
| *.msix | ||
| *.msm | ||
| *.msp | ||
|
|
||
| # Windows shortcuts | ||
| *.lnk | ||
|
|
||
| # End of https://www.toptal.com/developers/gitignore/api/windows | ||
|
|
||
| #Added by cargo | ||
|
|
||
| /target | ||
| Cargo.lock | ||
|
|
||
| .pnp.* | ||
| .yarn/* | ||
| !.yarn/patches | ||
| !.yarn/plugins | ||
| !.yarn/releases | ||
| !.yarn/sdks | ||
| !.yarn/versions | ||
|
|
||
| *.node | ||
|
|
||
| # Manually added | ||
|
|
||
| /index.d.ts | ||
| /index.js | ||
| /docs/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| target | ||
| Cargo.lock | ||
| .cargo | ||
| .github | ||
| npm | ||
| .eslintrc | ||
| .prettierignore | ||
| rustfmt.toml | ||
| yarn.lock | ||
| *.node | ||
| .yarn | ||
| __test__ | ||
| renovate.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /.yarn/ | ||
| index.js | ||
| *.md |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| nodeLinker: node-modules | ||
|
|
||
| yarnPath: .yarn/releases/yarn-4.1.0.cjs |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||
| [package] | ||||||
| name = "voicevox_core_node_api" | ||||||
| version = "0.0.0" | ||||||
| edition.workspace = true | ||||||
| publish.workspace = true | ||||||
|
|
||||||
| [lib] | ||||||
| crate-type = ["cdylib"] | ||||||
|
|
||||||
| [features] | ||||||
| cuda = ["voicevox_core/cuda"] | ||||||
| directml = ["voicevox_core/directml"] | ||||||
|
|
||||||
| [dependencies] | ||||||
| napi = { version = "2.16.0", features = ["napi4", "serde-json", "tokio_rt"] } | ||||||
| napi-derive = "2.16.0" | ||||||
| voicevox_core.workspace = true | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| serde.workspace = true | ||||||
| serde_json.workspace = true | ||||||
| uuid.workspace = true | ||||||
|
|
||||||
| [build-dependencies] | ||||||
| napi-build = "2" | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,56 @@ | ||||||
| # voicevox_core_node_api | ||||||
|
|
||||||
| VOICEVOX CORE の Node.js バインディングです。 | ||||||
|
|
||||||
| ## 環境構築 | ||||||
|
|
||||||
| 以下の環境が必要です。 | ||||||
|
|
||||||
| - Rustup | ||||||
| - Node > 10.0.0 | ||||||
|
|
||||||
| ## ファイル構成 | ||||||
|
|
||||||
| ```console | ||||||
| . | ||||||
| ├── build.rs | ||||||
| ├── Cargo.toml : Rust プロジェクトとしてのマニフェストファイルです。 | ||||||
| ├── exports : blocking および promises 名前空間下のクラスを再エクスポートするためのモジュールです。 | ||||||
| │ ├── blocking.d.ts | ||||||
| │ ├── blocking.js | ||||||
| │ ├── promises.d.ts | ||||||
| │ └── promises.js | ||||||
| ├── package.json | ||||||
| ├── README.md | ||||||
| ├── src : Rust で書かれたソースファイルです。 | ||||||
| │ └── ... | ||||||
| ├── __test__ : TypeScript と AVA によるテストのソースファイルです。 | ||||||
| │ └── ... | ||||||
| ├── tsconfig.json | ||||||
| └── yarn.lock | ||||||
| ``` | ||||||
|
|
||||||
| ## ビルド | ||||||
|
|
||||||
| npm で依存ライブラリをダウンロードし、`build` タスクによって `index.d.ts`, `index.js` および `node` 拡張子のネイティブモジュールを生成します。 | ||||||
|
|
||||||
| ```console | ||||||
| ❯ npm install | ||||||
| ❯ npm run build | ||||||
| ``` | ||||||
|
|
||||||
| ## テスト | ||||||
|
|
||||||
| `npm test` でテストを行うことができます。 | ||||||
|
|
||||||
| ```console | ||||||
| ❯ npm test | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. テスト前に 参考: voicevox_core/.github/workflows/test.yml Line 279 in 18aec9f
voicevox_core/.github/workflows/test.yml Line 315 in 18aec9f
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "test": "run-s test:build-util test:ava",
"test:build-util": "cargo build -p test_util",
"test:ava": "ava"npm-run-all2使うとこんな感じだと思います。 "test": "cargo build -p test_util && ava"でいいかも。avaにセットアップのHookがあるならそれでビルドしてもいいかも? |
||||||
| ``` | ||||||
|
|
||||||
| ## ドキュメント | ||||||
|
|
||||||
| `npm run docs` でドキュメントを生成できます。 | ||||||
|
|
||||||
| ```console | ||||||
| ❯ npm run docs | ||||||
| ``` | ||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||
| import path from "path"; | ||||||||
| import { AccentPhrase, Mora } from "voicevox_core"; | ||||||||
|
|
||||||||
| export const openJtalkDicDir = path.join( | ||||||||
| __dirname, | ||||||||
| "..", | ||||||||
| "..", | ||||||||
| "test_util", | ||||||||
| "data", | ||||||||
| "open_jtalk_dic_utf_8-1.11", | ||||||||
| ); | ||||||||
| export const modelFile = path.join( | ||||||||
| __dirname, | ||||||||
| "..", | ||||||||
| "..", | ||||||||
| "..", | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| "model", | ||||||||
| "sample.vvm", | ||||||||
| ); | ||||||||
|
|
||||||||
| export function checkAllMoras( | ||||||||
| accentPhrases: AccentPhrase[], | ||||||||
| otherAccentPhrases: AccentPhrase[], | ||||||||
| checker: (mora: Mora, otherMora: Mora) => boolean, | ||||||||
| ): boolean { | ||||||||
| for (let i = 0; i < accentPhrases.length; i++) { | ||||||||
| const accentPhrase = accentPhrases[i]; | ||||||||
| for (let j = 0; j < accentPhrase.moras.length; j++) { | ||||||||
| const mora = accentPhrase.moras[j]; | ||||||||
| const otherMora = otherAccentPhrases[i].moras[j]; | ||||||||
| if (!checker(mora, otherMora)) { | ||||||||
| return false; | ||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
| return true; | ||||||||
| } | ||||||||
Uh oh!
There was an error while loading. Please reload this page.