Skip to content

feat(cli): po video 模块子命令(video2mp3 / audio2txt / mark2video / txt2mp3) #4

Open

Description

@edwinjhlee

从 #3 拆出。核心 CLI(#1,分支 `x-cmd-261025-po-cli\)已落地;本 issue 是 video 模块的增量。

命令(4 个)

命令 说明 依赖
video2mp3 视频提取音频 povideo + moviepy
audio2txt 音频转文字(腾讯云,appid/secret_id/secret_key 为 required 选项) povideo
mark2video 视频加水印 povideo + moviepy
txt2mp3 文字转语音(speak 为 BOOL 参数,库默认 True) povideo

注册表条目(可直接贴入 office/cli/commands.py,源出提交 e5dbc8a)

```python
"video": {
"module": "office.api.video",
"help": "Audio/video: to mp3, speech-to-text, watermark, text-to-speech",
"platforms": None,
"commands": {
"video2mp3": {"help": "Extract audio from video", "params": [
{"name": "path", "positional": True, "metavar": "VIDEO", "help": "input video"},
{"name": "mp3_name", "help": "MP3 file name"},
{"name": "output_path", "default": "./", "help": "output directory"}]},
"audio2txt": {"help": "Audio to text (Tencent Cloud)", "params": [
{"name": "audio_path", "positional": True, "metavar": "AUDIO", "help": "input audio"},
{"name": "appid", "required": True, "help": "Tencent Cloud AppID"},
{"name": "secret_id", "required": True, "help": "Tencent Cloud SecretId"},
{"name": "secret_key", "required": True, "help": "Tencent Cloud SecretKey"}]},
"mark2video": {"help": "Add watermark to video", "params": [
{"name": "video_path", "positional": True, "metavar": "VIDEO", "help": "input video"},
{"name": "output_path", "default": "./", "help": "output directory"},
{"name": "output_name", "default": "mark2video.mp4", "help": "output file name"},
{"name": "mark_str", "default": "www.python-office.com", "help": "watermark text"},
{"name": "font_size", "type": int, "default": 28, "help": "font size"},
{"name": "font_type", "default": "Arial", "help": "font"},
{"name": "font_color", "default": "white", "help": "color"}]},
"txt2mp3": {"help": "Text to speech", "params": [
{"name": "content", "positional": True, "metavar": "TEXT", "help": "text content"},
{"name": "file", "help": "text file (overrides content)"},
{"name": "mp3", "default": "./程序员晚枫.mp3", "help": "output MP3"},
{"name": "speak", "type": "bool", "default": True, "help": "speak aloud"}]},
},
},
```

实现步骤(边测试边实现)

  • pip install povideo(office 已懒加载,只影响分发,不影响核心 CLI)
  • 贴入注册表条目;更新 `tests/test_code/test_cli.py` 的模块集合断言(42 → 46)
  • pytest 冒烟 + 解析回归(重点:txt2mp3 的 `--speak false` BOOL 解析)
  • `.x-cmd/test.sh` real 模式:video2mp3 真实产物校验(生成测试视频可用 ffmpeg)
  • audio2txt 需腾讯云凭据,E2E 只测缺凭据的报错路径

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions