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

C API用のzipファイルからmodelディレクトリをなくし、別でmodelダウンロード可能にする #603

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
57212bb
modelのzipファイルをアップロード
Hiroshiba Sep 9, 2023
0ef03a6
スクリプト版のダウンローダを消去する
Hiroshiba Sep 9, 2023
a6826cd
Merge branch 'スクリプト版のダウンローダを消去する' into コアのmodelディレクトリを分離
Hiroshiba Sep 9, 2023
2359609
ダウンローダーの更新
Hiroshiba Sep 9, 2023
887d615
modelディレクトリができてしまった
Hiroshiba Sep 9, 2023
035d3b1
製品版のバージョンを変更
Hiroshiba Sep 9, 2023
5ee41c4
Merge branch 'main' into コアのmodelディレクトリを分離
Hiroshiba Sep 12, 2023
4548853
github.event.inputs→inputs
Hiroshiba Sep 12, 2023
74ae74e
download_testをデフォルトでprerelease-latestが使われるように変更
Hiroshiba Sep 12, 2023
2e93f10
Merge remote-tracking branch 'upstream/main' into コアのmodelディレクトリを分離
Hiroshiba Oct 10, 2023
7889fa6
Merge remote-tracking branch 'upstream/main' into コアのmodelディレクトリを分離
Hiroshiba Oct 11, 2023
d5c370f
0.15.0-preview.2
Hiroshiba Oct 11, 2023
a948eb5
Merge remote-tracking branch 'upstream/main' into コアのmodelディレクトリを分離
Hiroshiba Oct 12, 2023
936ad70
修正漏れ
Hiroshiba Oct 12, 2023
ee48bcb
cargo run -p download -- -h
Hiroshiba Oct 12, 2023
d014d31
Apply suggestions from code review
Hiroshiba Oct 12, 2023
6bc9d62
変なとこが変わってた
Hiroshiba Oct 12, 2023
cee87ce
modelディレクトリのコピーが不要
Hiroshiba Oct 12, 2023
95c8dcf
update VOICEVOX_FAT_RESOURCE_VERSION
Hiroshiba Oct 12, 2023
c504620
min指定時にmodelディレクトリは無いはず
Hiroshiba Oct 12, 2023
cbd3e5b
Merge remote-tracking branch 'upstream/main' into コアのmodelディレクトリを分離
Hiroshiba Oct 13, 2023
4b755bc
--core_repo ${{ github.repository }}
Hiroshiba Oct 13, 2023
ee013d9
ミス
Hiroshiba Oct 13, 2023
62b5584
&
Hiroshiba Oct 13, 2023
ed5c8a6
Update .github/workflows/download_test.yml
Hiroshiba Oct 13, 2023
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
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,
Copy link
Member

@qryxip qryxip Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここをrepo: RepoNameにしたのはC-CALLER-CONTROLに従った結果だったのですが、まあどちらでも良いと思います。

こういう考え方も主流ですし(というか私も普段書き殴るときはどちらかというとこっち側です)
https://twitter.com/qnighy/status/1008010536397651968

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あんま深いこと考えてなくて、find_gh_assetを2回呼ぶのでrepoが移譲?されちゃって以降で使えなくなっちゃったんで&つけた感じでした!

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
Loading