Skip to content

Commit 68591eb

Browse files
committed
fix funasr-runtime-bundle
1 parent f431f6f commit 68591eb

6 files changed

Lines changed: 14 additions & 8 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ bld/
3737
.cursor/
3838
.vs/
3939
.funasr_bundle_build/
40+
funasr-runtime-bundle.zip
41+
data/funasr-runtime-bundle.zip
4042
# Uncomment if you have tasks that create the project's static files in wwwroot
4143
#wwwroot/
4244

@@ -362,4 +364,4 @@ MigrationBackup/
362364
.ionide/
363365

364366
# Fody - auto-generated XML schema
365-
FodyWeavers.xsd
367+
FodyWeavers.xsd

App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<add key="FunAsrPipPackages" value="funasr modelscope torch torchaudio" />
4343
<!-- 预置运行时优先:推荐将可用 Python 环境打包为 zip,运行时解压即用 -->
4444
<add key="FunAsrPreferPrebuiltRuntime" value="true" />
45-
<add key="FunAsrRuntimeBundlePath" value="funasr-runtime-bundle.zip" />
45+
<add key="FunAsrRuntimeBundlePath" value="data\funasr-runtime-bundle.zip" />
4646
<!-- 默认关闭在线安装回退,避免复杂自动步骤 -->
4747
<add key="FunAsrAllowOnlineInstallFallback" value="false" />
4848
<add key="FunAsrInstallUseNoDepsStrategy" value="true" />

FunAsrRuntimeManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private static async Task<FunAsrRuntimeBootstrapResult> EnsureReadyInternalAsync
123123
string runtimeRoot = Path.Combine(appData, "TimeTask", "funasr-runtime");
124124
bool preferPrebuiltRuntime = ReadBool("FunAsrPreferPrebuiltRuntime", true);
125125
bool allowOnlineInstallFallback = ReadBool("FunAsrAllowOnlineInstallFallback", false);
126-
string bundlePath = ReadString("FunAsrRuntimeBundlePath", "funasr-runtime-bundle.zip");
126+
string bundlePath = ReadString("FunAsrRuntimeBundlePath", @"data\funasr-runtime-bundle.zip");
127127

128128
Directory.CreateDirectory(runtimeRoot);
129129
VoiceRuntimeLog.Info($"FunASR runtime strategy: preferPrebuiltRuntime={preferPrebuiltRuntime}, allowOnlineInstallFallback={allowOnlineInstallFallback}, bundlePath={bundlePath}");

TimeTask.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@
237237
<None Include="scripts\funasr_asr.py">
238238
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
239239
</None>
240-
<None Include="funasr-runtime-bundle.zip" Condition="Exists('funasr-runtime-bundle.zip')">
240+
<None Include="data\funasr-runtime-bundle.zip" Condition="Exists('data\funasr-runtime-bundle.zip')">
241241
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
242242
</None>
243243
<None Include="Properties\Settings.settings">

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ This application uses Large Language Models (LLMs) to provide features like auto
133133

134134
FunASR 本地子进程模式:
135135
* `VoiceAsrProvider=funasr` 时,程序会在每段语音结束后调用本地 Python 脚本 `scripts/funasr_asr.py` 进行识别。
136-
* 推荐使用“预置运行时包”模式:将可用 Python 环境打包为 `funasr-runtime-bundle.zip`,程序启动时自动解压并直接使用。
136+
* 推荐使用“预置运行时包”模式:将可用 Python 环境打包为 `data/funasr-runtime-bundle.zip`,程序启动时自动解压并直接使用。
137137
* 推荐最小流程(开发机一次性操作):
138138
* `powershell -ExecutionPolicy Bypass -File scripts/build_funasr_runtime_bundle.ps1 -PythonExe "<你的 py311 路径>"`
139-
* 将生成的 `funasr-runtime-bundle.zip` 放到程序目录(如 `bin\Release`)
139+
* 默认会生成到 `data/funasr-runtime-bundle.zip`。
140140
* 默认启用 `FunAsrUsePersistentWorker=true`:使用常驻子进程复用已加载模型,避免每段语音都重复加载模型导致超时。
141141
* 当 `FunAsrPreferPrebuiltRuntime=true` 且 `FunAsrAllowOnlineInstallFallback=false` 时,未找到预置包将直接提示不可用(不会进入复杂在线安装流程)。
142142
* 一般无需用户手动执行 `pip install`;仅在网络受限或被安全策略拦截时,才需要手动处理。
@@ -155,7 +155,7 @@ FunASR 本地子进程模式:
155155
<add key="FunAsrScriptPath" value="scripts\funasr_asr.py" />
156156
<add key="FunAsrModel" value="iic/SenseVoiceSmall" />
157157
<add key="FunAsrPreferPrebuiltRuntime" value="true" />
158-
<add key="FunAsrRuntimeBundlePath" value="funasr-runtime-bundle.zip" />
158+
<add key="FunAsrRuntimeBundlePath" value="data\funasr-runtime-bundle.zip" />
159159
<add key="FunAsrAllowOnlineInstallFallback" value="false" />
160160
<add key="FunAsrDevice" value="cpu" />
161161
<add key="FunAsrAutoBootstrap" value="true" />

scripts/build_funasr_runtime_bundle.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
param(
22
[string]$PythonExe = "python",
3-
[string]$OutputZip = "funasr-runtime-bundle.zip",
3+
[string]$OutputZip = "data\funasr-runtime-bundle.zip",
44
[string]$WorkDir = ".funasr_bundle_build",
55
[string]$RuntimeDeps = "modelscope torch torchaudio numpy scipy librosa soundfile kaldiio torch-complex sentencepiece jieba pytorch-wpe oss2 tqdm umap-learn jaconv hydra-core tensorboardX requests pyyaml jamo"
66
)
@@ -34,6 +34,10 @@ Run-Step $venvPython "-m pip install --prefer-binary --no-deps funasr"
3434
Run-Step $venvPython "-c `"import funasr,modelscope,torch,numpy,scipy;print('ok')`""
3535

3636
$outputPath = Join-Path $root $OutputZip
37+
$outputDir = Split-Path -Parent $outputPath
38+
if (-not [string]::IsNullOrWhiteSpace($outputDir)) {
39+
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
40+
}
3741
if (Test-Path $outputPath) {
3842
Remove-Item $outputPath -Force
3943
}

0 commit comments

Comments
 (0)