yuanflow-cli 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuanflow-cli",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "YuanFlow API CLI and skill installer for supported AI coding agents.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -25,12 +25,19 @@ description: 仅当用户明确要求使用本地音视频转文字、本地转
25
25
 
26
26
  本 Skill 的脚本目录为当前 Skill 目录下的 `scripts/`。
27
27
 
28
- 默认目录:
28
+ 默认运行目录:
29
29
 
30
- - 模型保存目录:`scripts/models`
31
- - 任务缓存目录:`scripts/cache`
32
- - 抽取音频目录:`scripts/cache/audio`
33
- - 转写文本目录:`scripts/cache/transcripts`
30
+ - Windows:`%APPDATA%/YuanFlow/runtime_tools/local-transcribe`
31
+ - 其它系统:`~/.yuanflow/runtime_tools/local-transcribe`
32
+
33
+ 默认子目录:
34
+
35
+ - 模型保存目录:`<运行目录>/models`
36
+ - 任务缓存目录:`<运行目录>/cache`
37
+ - 抽取音频目录:`<运行目录>/cache/audio`
38
+ - 转写文本目录:`<运行目录>/cache/transcripts`
39
+
40
+ 虚拟环境仍创建在当前 Skill 的 `scripts/.venv`,不要全局安装依赖。
34
41
 
35
42
  在 YuanFlow 程序内置环境中,`skill_read` 返回的 `config.managed_skill_dir` 是当前 Skill 的真实目录。执行脚本时优先以这个目录为基准:
36
43
 
@@ -38,14 +45,14 @@ description: 仅当用户明确要求使用本地音视频转文字、本地转
38
45
  cd "<config.managed_skill_dir>\scripts"
39
46
  ```
40
47
 
41
- 不要把模型下载到用户桌面、项目根目录或系统临时目录。不要把模型文件打包进 Skill 或 npm 包。
48
+ 不要把模型下载到用户桌面、项目根目录或系统临时目录。不要把模型文件打包进 Skill 或 npm 包。Windows 下 FunASR/SentencePiece 对中文路径不稳定,所以不要强制把模型放到中文 Skill 安装目录下。
42
49
 
43
50
  ## 首次使用模型下载规则
44
51
 
45
52
  开始转写前先检查模型目录是否已经存在:
46
53
 
47
- - `scripts/models/SenseVoiceSmall`
48
- - `scripts/models/fsmn-vad`
54
+ - `<运行目录>/models/SenseVoiceSmall`
55
+ - `<运行目录>/models/fsmn-vad`
49
56
 
50
57
  如果这两个目录都存在且不为空,直接执行后续任务。
51
58
 
@@ -54,7 +61,7 @@ cd "<config.managed_skill_dir>\scripts"
54
61
  - SenseVoice:`iic/SenseVoiceSmall`
55
62
  - VAD:`iic/speech_fsmn_vad_zh-cn-16k-common-pytorch`
56
63
 
57
- 下载由 `modelscope.snapshot_download()` 完成,保存到 `scripts/models`。下载完成后继续转写。
64
+ 下载由 `modelscope.snapshot_download()` 完成,保存到 `<运行目录>/models`。下载完成后继续转写。
58
65
 
59
66
  ## 执行流程
60
67
 
@@ -120,8 +127,8 @@ Set-Location -LiteralPath '<Skill目录>\scripts'; if (-not (Test-Path -LiteralP
120
127
  | 参数 | 说明 |
121
128
  | --- | --- |
122
129
  | `input_path` | 音频文件、视频文件或目录。 |
123
- | `--cache-root` | 缓存目录,默认 `scripts/cache`。 |
124
- | `--models-root` | 模型目录,默认 `scripts/models`。 |
130
+ | `--cache-root` | 缓存目录,默认 `<运行目录>/cache`。 |
131
+ | `--models-root` | 模型目录,默认 `<运行目录>/models`。 |
125
132
  | `--recursive` | 输入为目录时递归扫描。 |
126
133
  | `--device` | `auto`、`cpu`、`cuda:0` 等,默认 `auto`。 |
127
134
  | `--language` | `zh`、`en`、`yue`、`ja`、`ko`、`auto`,默认 `auto`。 |
@@ -152,10 +159,10 @@ Set-Location -LiteralPath '<Skill目录>\scripts'; if (-not (Test-Path -LiteralP
152
159
 
153
160
  只有用户明确要求删除缓存或模型文件时,才可以删除:
154
161
 
155
- - 缓存目录:`scripts/cache`
156
- - 模型目录:`scripts/models`
162
+ - 缓存目录:`<运行目录>/cache`
163
+ - 模型目录:`<运行目录>/models`
157
164
 
158
- 删除前必须确认目标路径位于当前 Skill `scripts/` 目录下,不能删除其它项目目录、用户桌面目录或系统目录。
165
+ 删除前必须确认目标路径位于 YuanFlow 本地转写运行目录下,不能删除其它项目目录、用户桌面目录、其它 Skill 或系统目录。
159
166
 
160
167
  ## 输出要求
161
168
 
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import json
4
+ import os
4
5
  import re
5
6
  from pathlib import Path
6
7
  from typing import Iterable
@@ -31,6 +32,13 @@ def ensure_dir(path: Path) -> Path:
31
32
  return path
32
33
 
33
34
 
35
+ def default_runtime_root() -> Path:
36
+ appdata = os.environ.get("APPDATA")
37
+ if appdata:
38
+ return Path(appdata) / "YuanFlow" / "runtime_tools" / "local-transcribe"
39
+ return Path.home() / ".yuanflow" / "runtime_tools" / "local-transcribe"
40
+
41
+
34
42
  def write_json(path: Path, data: object) -> Path:
35
43
  ensure_parent(path)
36
44
  path.write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
@@ -6,6 +6,7 @@ from pathlib import Path
6
6
  from common.media import extract_audio
7
7
  from common.sensevoice import build_model
8
8
  from common.sensevoice import clean_transcript
9
+ from common.utils import default_runtime_root
9
10
  from common.utils import ensure_dir
10
11
  from common.utils import is_audio_file
11
12
  from common.utils import is_video_file
@@ -15,8 +16,9 @@ from common.utils import write_text
15
16
 
16
17
 
17
18
  SCRIPT_DIR = Path(__file__).resolve().parent
18
- DEFAULT_CACHE_ROOT = SCRIPT_DIR / "cache"
19
- DEFAULT_MODELS_ROOT = SCRIPT_DIR / "models"
19
+ DEFAULT_RUNTIME_ROOT = default_runtime_root()
20
+ DEFAULT_CACHE_ROOT = DEFAULT_RUNTIME_ROOT / "cache"
21
+ DEFAULT_MODELS_ROOT = DEFAULT_RUNTIME_ROOT / "models"
20
22
 
21
23
 
22
24
  def prepare_audio(