Skip to content

Commit

Permalink
C API用のzipファイルからmodelディレクトリをなくし、別でmodelダウンロード可能にする (#603)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryo Yamashita <[email protected]>
  • Loading branch information
Hiroshiba and qryxip authored Oct 13, 2023
1 parent 9af99c4 commit bd7f4db
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 20 deletions.
48 changes: 38 additions & 10 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ on:

env:
VOICEVOX_RESOURCE_VERSION: "0.15.0-preview.3"
VOICEVOX_FAT_RESOURCE_VERSION: "0.15.0-preview.3"
VOICEVOX_FAT_RESOURCE_VERSION: "0.15.0-preview.4"
# releaseタグ名か、workflow_dispatchでのバージョン名か、'0.0.0'が入る
VERSION: ${{ github.event.release.tag_name || inputs.version || '0.0.0' }}
PRODUCTION_REPOSITORY_TAG: "0.15.0-preview.2" # 製品版のタグ名
Expand Down Expand Up @@ -239,19 +239,11 @@ jobs:
repository: VOICEVOX/voicevox_resource
ref: ${{ env.VOICEVOX_RESOURCE_VERSION }}
path: download/resource
- name: Checkout VOICEVOX FAT RESOURCE
if: inputs.is_production
uses: actions/checkout@v3
with:
repository: VOICEVOX/voicevox_fat_resource
ref: ${{ env.VOICEVOX_FAT_RESOURCE_VERSION }}
path: download/fat_resource
- name: Raplace resource
if: inputs.is_production
shell: bash
run: |
mv -f download/resource/core/README.md ./README.md
rm -r ./model; mv download/fat_resource/core/model ./model
- name: Install cargo-binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install cargo-edit
Expand Down Expand Up @@ -315,7 +307,6 @@ jobs:
# libonnxruntimeについてはバージョン付のshared libraryを使用するためバージョンがついてないものを削除する
rm -f artifact/${{ env.ASSET_NAME }}/libonnxruntime.{so,dylib}
cp -v README.md "artifact/${{ env.ASSET_NAME }}/README.txt"
cp -vr model "artifact/${{ env.ASSET_NAME }}/"
echo "${{ env.VERSION }}" > "artifact/${{ env.ASSET_NAME }}/VERSION"
mkdir java_artifact
Expand Down Expand Up @@ -417,6 +408,43 @@ jobs:
${{ env.ASSET_NAME }}.zip
target_commitish: ${{ github.sha }}

deploy_model:
runs-on: ubuntu-latest
needs: config
env:
ASSET_NAME: model-${{ needs.config.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Checkout VOICEVOX FAT RESOURCE
if: inputs.is_production
uses: actions/checkout@v3
with:
repository: VOICEVOX/voicevox_fat_resource
ref: ${{ env.VOICEVOX_FAT_RESOURCE_VERSION }}
path: download/fat_resource
- name: Raplace resource
if: inputs.is_production
shell: bash
run: |
rm -r ./model; mv download/fat_resource/core/model ./model
- name: Create artifact
run: |
mkdir "artifact"
mv model "artifact/${{ env.ASSET_NAME }}/"
- name: Archive artifact
run: |
cd artifact
7z a "../${{ env.ASSET_NAME }}.zip" "${{ env.ASSET_NAME }}"
- name: Upload to Release
if: fromJson(needs.config.outputs.deploy)
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: ${{ env.VERSION }}
files: |-
${{ env.ASSET_NAME }}.zip
target_commitish: ${{ github.sha }}

build_java_package:
runs-on: ubuntu-latest
if: ${{ !(github.event_name != 'release' && github.event_name != 'workflow_dispatch') }} # !env.IS_SIMPLE_TEST と同じ
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/download_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ jobs:
download_dir: voicevox_core
check_items: |
voicevox_core.dll
model/README.*
README.txt
check_not_exists_items: |
*directml*
Expand All @@ -97,6 +96,7 @@ jobs:
*nvidia*
*cufft*
*curand*
model/README.*
open_jtalk_dic_utf_8-1.11
- name: DirectML option確認
os: windows-latest
Expand All @@ -123,7 +123,6 @@ jobs:
download_dir: voicevox_core
check_items: |
voicevox_core.dll
model/README.*
README.txt
check_not_exists_items: |
*cuda*
Expand All @@ -134,6 +133,7 @@ jobs:
*curand*
Directml.dll
DirectML_LICENSE.txt
model/README.*
open_jtalk_dic_utf_8-1.11
- name: cuda option確認
os: windows-latest
Expand Down Expand Up @@ -163,7 +163,6 @@ jobs:
download_dir: voicevox_core
check_items: |
voicevox_core.dll
model/README.*
README.txt
check_not_exists_items: |
*directml*
Expand All @@ -178,6 +177,7 @@ jobs:
cudnn_ops_infer64_*.dll
cufft64_*.dll
curand64_*.dll
model/README.*
open_jtalk_dic_utf_8-1.11
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}-${{ matrix.os }}
Expand All @@ -196,7 +196,7 @@ jobs:
)
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Execute download command
run: ${{ matrix.download_command }} --version ${{ env.VERSION }}
run: ${{ matrix.download_command }} --version ${{ env.VERSION }} --core-repo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check downloaded version
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# VOICEVOX CORE

## **現在のmainブランチは工事中なので正しく動かないことがあります。[バージョン0.14.4](https://github.com/VOICEVOX/voicevox_core/tree/0.14.4)をご利用ください。**
## **現在の main ブランチは工事中なので正しく動かないことがあります。[バージョン 0.14.4](https://github.com/VOICEVOX/voicevox_core/tree/0.14.4)をご利用ください。**

[![releases](https://img.shields.io/github/v/release/VOICEVOX/voicevox_core?label=release)](https://github.com/VOICEVOX/voicevox_core/releases)
[![test](https://github.com/VOICEVOX/voicevox_core/actions/workflows/test.yml/badge.svg)](https://github.com/VOICEVOX/voicevox_core/actions/workflows/test.yml)
Expand All @@ -15,6 +15,7 @@
全体構成は [こちら](https://github.com/VOICEVOX/voicevox/blob/main/docs/%E5%85%A8%E4%BD%93%E6%A7%8B%E6%88%90.md) に詳細があります。)

## 貢献者の方へ

Issue を解決するプルリクエストを作成される際は、別の方と同じ Issue に取り組むことを避けるため、
Issue 側で取り組み始めたことを伝えるか、最初に Draft プルリクエストを作成してください。

Expand Down Expand Up @@ -152,6 +153,15 @@ DLL用のヘッダファイルは [crates/voicevox\_core\_c\_api/include/voicevo
cargo test
```

## ダウンローダーの実行

```bash
cargo run -p download

# ヘルプを表示
cargo run -p download -- -h
```

## ヘッダファイルの更新

```bash
Expand All @@ -177,7 +187,8 @@ typos
**[voicevoxcore4s](https://github.com/windymelt/voicevoxcore4s) [@windymelt](https://github.com/windymelt)** ・・・ VOICEVOX CORE の Scala(JVM) 向け FFI ラッパー
**[voicevox_flutter](https://github.com/char5742/voicevox_flutter) [@char5742](https://github.com/char5742)** ・・・ VOICEVOX CORE の Flutter 向け FFI ラッパー
**[voicevoxcore.go](https://github.com/sh1ma/voicevoxcore.go) [@sh1ma](https://github.com/sh1ma)** ・・・ VOICEVOX CORE の Go 言語 向け FFI ラッパー
**[VoicevoxCoreSharp](https://github.com/yamachu/VoicevoxCoreSharp) [@yamachu](https://github.com/yamachu)** ・・・ VOICEVOX CORE の C# 向け FFI ラッパー
**[VoicevoxCoreSharp](https://github.com/yamachu/VoicevoxCoreSharp) [@yamachu](https://github.com/yamachu)** ・・・ VOICEVOX CORE の C# 向け FFI ラッパー

## ライセンス

ソースコードのライセンスは [MIT LICENSE](./LICENSE) です。
Expand Down
20 changes: 16 additions & 4 deletions crates/download/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async fn main() -> anyhow::Result<()> {

let octocrab = &octocrab()?;

let core = find_gh_asset(octocrab, core_repo, &version, |tag| {
let core = find_gh_asset(octocrab, &core_repo, &version, |tag| {
let device = match (os, device) {
(Os::Linux, Device::Cuda) => "gpu",
(_, device) => device.into(),
Expand All @@ -167,10 +167,15 @@ async fn main() -> anyhow::Result<()> {
})
.await?;

let model = find_gh_asset(octocrab, &core_repo, &version, |tag| {
format!("model-{tag}.zip")
})
.await?;

let additional_libraries = OptionFuture::from((device != Device::Cpu).then(|| {
find_gh_asset(
octocrab,
additional_libraries_repo,
&additional_libraries_repo,
&additional_libraries_version,
|_| {
let device = match device {
Expand Down Expand Up @@ -205,6 +210,13 @@ async fn main() -> anyhow::Result<()> {
)?);

if !min {
tasks.spawn(download_and_extract_from_gh(
model,
Stripping::FirstDir,
&output.join("model"),
&progresses,
)?);

if let Some(additional_libraries) = additional_libraries {
tasks.spawn(download_and_extract_from_gh(
additional_libraries,
Expand Down Expand Up @@ -255,7 +267,7 @@ fn octocrab() -> octocrab::Result<Arc<Octocrab>> {

async fn find_gh_asset(
octocrab: &Arc<Octocrab>,
repo: RepoName,
repo: &RepoName,
git_tag_or_latest: &str,
asset_name: impl FnOnce(&str) -> String,
) -> anyhow::Result<GhAsset> {
Expand All @@ -281,7 +293,7 @@ async fn find_gh_asset(

Ok(GhAsset {
octocrab: octocrab.clone(),
repo,
repo: repo.clone(),
tag: tag_name,
id,
name,
Expand Down

0 comments on commit bd7f4db

Please sign in to comment.