chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:25:10 +08:00
commit c397331b1e
3684 changed files with 990993 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
# FunASR Colab Quickstart
English | [简体中文](README_zh.md) | [日本語](README_ja.md) | [한국어](README_ko.md)
Run FunASR in a browser without preparing a local Python environment.
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/modelscope/FunASR/blob/main/examples/colab/funasr_quickstart.ipynb)
## What the notebook covers
- Install FunASR and runtime dependencies in Colab.
- Pick `cuda:0` automatically when a Colab GPU is available, otherwise use CPU.
- Transcribe a public sample audio file with `paraformer-zh`, VAD, and punctuation.
- Upload your own audio file and run the same model.
- Save the transcript JSON for sharing or issue reports.
## Notes
- The first run downloads model files and may take a few minutes.
- CPU runtime works for a quick smoke test; GPU runtime is faster for longer audio.
- If you are evaluating production deployment, use the [deployment matrix](../../docs/deployment_matrix.md) after the notebook works.
- For OpenAI-compatible HTTP service testing, use [examples/openai_api](../openai_api/).
## Troubleshooting
| Symptom | What to try |
|---|---|
| Colab runtime disconnects or resets | Reconnect the runtime, rerun the install cell, then rerun the model cell. The notebook does not persist Python packages across runtime resets. |
| GPU is unavailable | Use `Runtime > Change runtime type > GPU`. If no GPU is assigned, the notebook still works on CPU for a short smoke test. |
| Model download is slow | Rerun the cell after the network recovers. The first run downloads model files and later runs in the same runtime are faster. |
| Uploaded audio fails or is too large | Try a short WAV/MP3 first. For long files, trim a representative sample before using Colab. |
| Output is unexpected | Save the transcript JSON cell output and include it when opening an issue. |
Notebook source: [funasr_quickstart.ipynb](https://github.com/modelscope/FunASR/blob/main/examples/colab/funasr_quickstart.ipynb).
+34
View File
@@ -0,0 +1,34 @@
# FunASR Colab クイックスタート
[English](README.md) | [简体中文](README_zh.md) | 日本語 | [한국어](README_ko.md)
ローカルの Python 環境を準備せずに、ブラウザだけで FunASR を実行できます。
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/modelscope/FunASR/blob/main/examples/colab/funasr_quickstart.ipynb)
## Notebook で試せること
- Colab に FunASR と実行時依存関係をインストールします。
- Colab の GPU が使える場合は自動で `cuda:0` を選び、なければ CPU を使います。
- `paraformer-zh`、VAD、句読点モデルで公開サンプル音声を文字起こしします。
- 自分の音声ファイルをアップロードし、同じモデルで文字起こしします。
- transcript JSON を保存し、共有、比較、issue 報告に利用できます。
## 利用メモ
- 初回実行ではモデルファイルをダウンロードするため、数分かかる場合があります。
- CPU runtime は短い smoke test に使えます。長い音声では GPU runtime の方が高速です。
- 本番デプロイを評価する場合は、notebook が動いた後に [deployment matrix](../../docs/deployment_matrix.md) を確認してください。
- OpenAI 互換 HTTP サービスを試す場合は [examples/openai_api](../openai_api/README_ja.md) を利用してください。
## トラブルシューティング
| 症状 | 対処 |
|---|---|
| Colab runtime が切断またはリセットされる | runtime に再接続し、install cell を実行してから model cell を再実行します。runtime リセット後は Python パッケージが保持されません。 |
| GPU が使えない | `Runtime > Change runtime type > GPU` に変更します。GPU が割り当てられない場合でも、短い smoke test は CPU で実行できます。 |
| モデルのダウンロードが遅い | ネットワークが回復してから cell を再実行します。初回はモデルファイルをダウンロードし、同じ runtime の後続実行は速くなります。 |
| アップロードした音声が失敗する、または大きすぎる | まず短い WAV/MP3 で確認してください。長い音声は代表的な区間に切り出してから Colab で試します。 |
| 出力が期待と違う | transcript JSON cell の出力を保存し、issue を作成するときに添付してください。 |
Notebook source: [funasr_quickstart.ipynb](https://github.com/modelscope/FunASR/blob/main/examples/colab/funasr_quickstart.ipynb).
+34
View File
@@ -0,0 +1,34 @@
# FunASR Colab 빠른 시작
[English](README.md) | [简体中文](README_zh.md) | [日本語](README_ja.md) | 한국어
로컬 Python 환경을 준비하지 않고 브라우저에서 바로 FunASR을 실행할 수 있습니다.
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/modelscope/FunASR/blob/main/examples/colab/funasr_quickstart.ipynb)
## Notebook에서 확인할 수 있는 것
- Colab에 FunASR과 런타임 의존성을 설치합니다.
- Colab GPU가 있으면 자동으로 `cuda:0`을 사용하고, 없으면 CPU를 사용합니다.
- `paraformer-zh`, VAD, 문장부호 모델로 공개 샘플 오디오를 전사합니다.
- 직접 업로드한 오디오 파일을 같은 모델로 전사합니다.
- transcript JSON을 저장하여 공유, 비교, issue 보고에 활용할 수 있습니다.
## 사용 메모
- 첫 실행에서는 모델 파일을 다운로드하므로 몇 분이 걸릴 수 있습니다.
- CPU runtime은 짧은 smoke test에 적합합니다. 긴 오디오에는 GPU runtime이 더 빠릅니다.
- 프로덕션 배포를 검토하려면 notebook을 먼저 실행한 뒤 [deployment matrix](../../docs/deployment_matrix.md)를 확인하세요.
- OpenAI 호환 HTTP 서비스를 테스트하려면 [examples/openai_api](../openai_api/README_ko.md)를 사용하세요.
## 문제 해결
| 증상 | 해결 방법 |
|---|---|
| Colab runtime이 끊기거나 재설정됨 | runtime에 다시 연결한 뒤 install cell을 먼저 실행하고 model cell을 다시 실행하세요. runtime이 재설정되면 설치된 Python 패키지가 유지되지 않습니다. |
| GPU를 사용할 수 없음 | `Runtime > Change runtime type > GPU`로 변경하세요. GPU가 배정되지 않아도 짧은 smoke test는 CPU로 실행할 수 있습니다. |
| 모델 다운로드가 느림 | 네트워크가 안정된 뒤 cell을 다시 실행하세요. 첫 실행은 모델 파일을 다운로드하며, 같은 runtime의 이후 실행은 더 빠릅니다. |
| 업로드한 오디오가 실패하거나 너무 큼 | 먼저 짧은 WAV/MP3로 확인하세요. 긴 오디오는 대표 구간을 잘라 Colab에서 테스트하는 것이 좋습니다. |
| 출력이 예상과 다름 | transcript JSON cell 출력을 저장하고 issue를 열 때 함께 첨부하세요. |
Notebook source: [funasr_quickstart.ipynb](https://github.com/modelscope/FunASR/blob/main/examples/colab/funasr_quickstart.ipynb).
+34
View File
@@ -0,0 +1,34 @@
# FunASR Colab 快速体验
[English](README.md) | 简体中文 | [日本語](README_ja.md) | [한국어](README_ko.md)
无需提前配置本地 Python 环境,直接在浏览器里运行 FunASR。
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/modelscope/FunASR/blob/main/examples/colab/funasr_quickstart.ipynb)
## Notebook 覆盖内容
- 在 Colab 中安装 FunASR 和运行依赖。
- 如果 Colab runtime 有 GPU,自动使用 `cuda:0`;否则使用 CPU。
- 使用 `paraformer-zh`、VAD 和标点模型转写公开样例音频。
- 上传自己的音频文件,并用同一套模型运行转写。
- 保存 transcript JSON,便于分享、对比或提交 issue。
## 使用建议
- 第一次运行会下载模型文件,可能需要几分钟。
- CPU runtime 适合快速 smoke test;长音频建议切换到 GPU runtime。
- 如果要评估生产部署,先跑通 notebook,再阅读 [部署选型表](../../docs/deployment_matrix_zh.md)。
- 如果要测试 OpenAI 兼容 HTTP 服务,请使用 [examples/openai_api](../openai_api/README_zh.md)。
## 故障排查
| 现象 | 处理方式 |
|---|---|
| Colab runtime 断开或重置 | 重新连接 runtime,先重跑安装单元,再重跑模型单元。runtime 重置后不会保留已安装的 Python 包。 |
| 没有 GPU | 通过 `Runtime > Change runtime type > GPU` 切换。没有分配到 GPU 时,短音频 smoke test 仍可用 CPU 跑通。 |
| 模型下载很慢 | 网络恢复后重跑该单元。第一次运行会下载模型文件,同一个 runtime 后续运行会更快。 |
| 上传音频失败或文件太大 | 先用短 WAV/MP3 验证。长音频建议截取有代表性的片段再放到 Colab。 |
| 输出不符合预期 | 保存 transcript JSON 单元输出,提交 issue 时一起附上。 |
Notebook 源文件:[funasr_quickstart.ipynb](https://github.com/modelscope/FunASR/blob/main/examples/colab/funasr_quickstart.ipynb)。
+160
View File
@@ -0,0 +1,160 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# FunASR Colab Quickstart\n",
"\n",
"Run FunASR in a browser, transcribe a public sample, then try your own audio file.\n",
"\n",
"Repository: https://github.com/modelscope/FunASR\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Install dependencies\n",
"\n",
"The first cell can take a few minutes because it installs FunASR and downloads Python wheels. Colab already includes PyTorch in most runtimes.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip -q install -U funasr modelscope soundfile"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. Select CPU or GPU\n",
"\n",
"For a faster run, choose **Runtime -> Change runtime type -> GPU** in Colab before running the notebook.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"import torch\n",
"\n",
"device = \"cuda:0\" if torch.cuda.is_available() else \"cpu\"\n",
"print(f\"Using device: {device}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3. Transcribe a public sample\n",
"\n",
"This uses `paraformer-zh` with VAD and punctuation so the example works with a short public Mandarin sample.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from funasr import AutoModel\n",
"\n",
"sample_url = \"https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/vad_example.wav\"\n",
"\n",
"model = AutoModel(\n",
" model=\"paraformer-zh\",\n",
" vad_model=\"fsmn-vad\",\n",
" punc_model=\"ct-punc\",\n",
" device=device,\n",
")\n",
"\n",
"result = model.generate(input=sample_url, batch_size_s=60)\n",
"print(json.dumps(result, ensure_ascii=False, indent=2))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4. Try your own audio file\n",
"\n",
"Upload a short `.wav`, `.mp3`, `.m4a`, or `.flac` file. For long recordings, split the audio or use a GPU runtime.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from google.colab import files\n",
"\n",
"uploaded = files.upload()\n",
"audio_path = next(iter(uploaded))\n",
"print(f\"Uploaded: {audio_path}\")\n",
"\n",
"user_result = model.generate(input=audio_path, batch_size_s=60)\n",
"print(json.dumps(user_result, ensure_ascii=False, indent=2))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 5. Save the transcript JSON\n",
"\n",
"Attach this JSON when you open a GitHub issue or compare model outputs.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"\n",
"Path(\"funasr_transcript.json\").write_text(\n",
" json.dumps(user_result, ensure_ascii=False, indent=2),\n",
" encoding=\"utf-8\",\n",
")\n",
"files.download(\"funasr_transcript.json\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Next steps\n",
"\n",
"- Choose a model: https://github.com/modelscope/FunASR/blob/main/docs/model_selection.md\n",
"- Compare with Whisper or cloud ASR: https://github.com/modelscope/FunASR/blob/main/docs/migration_from_whisper.md\n",
"- Deploy an OpenAI-compatible API: https://github.com/modelscope/FunASR/tree/main/examples/openai_api\n",
"- Read production deployment options: https://github.com/modelscope/FunASR/blob/main/docs/deployment_matrix.md\n"
]
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}