Files
FunASR/examples/colab/funasr_quickstart.ipynb
T
zhifu gao f31c1c4f8a docs: add Colab quickstart notebook
Add a browser-run FunASR Colab quickstart and link it from README, tutorial, use-case, and deployment docs.
2026-05-25 19:40:27 +08:00

4.5 KiB

FunASR Colab Quickstart

Run FunASR in a browser, transcribe a public sample, then try your own audio file.

Repository: https://github.com/modelscope/FunASR

1. Install dependencies

The first cell can take a few minutes because it installs FunASR and downloads Python wheels. Colab already includes PyTorch in most runtimes.

In [ ]:
!pip -q install -U funasr modelscope soundfile

2. Select CPU or GPU

For a faster run, choose Runtime -> Change runtime type -> GPU in Colab before running the notebook.

In [ ]:
import json
import torch

device = "cuda:0" if torch.cuda.is_available() else "cpu"
print(f"Using device: {device}")

3. Transcribe a public sample

This uses paraformer-zh with VAD and punctuation so the example works with a short public Mandarin sample.

In [ ]:
from funasr import AutoModel

sample_url = "https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/vad_example.wav"

model = AutoModel(
    model="paraformer-zh",
    vad_model="fsmn-vad",
    punc_model="ct-punc",
    device=device,
)

result = model.generate(input=sample_url, batch_size_s=60)
print(json.dumps(result, ensure_ascii=False, indent=2))

4. Try your own audio file

Upload a short .wav, .mp3, .m4a, or .flac file. For long recordings, split the audio or use a GPU runtime.

In [ ]:
from google.colab import files

uploaded = files.upload()
audio_path = next(iter(uploaded))
print(f"Uploaded: {audio_path}")

user_result = model.generate(input=audio_path, batch_size_s=60)
print(json.dumps(user_result, ensure_ascii=False, indent=2))

5. Save the transcript JSON

Attach this JSON when you open a GitHub issue or compare model outputs.

In [ ]:
from pathlib import Path

Path("funasr_transcript.json").write_text(
    json.dumps(user_result, ensure_ascii=False, indent=2),
    encoding="utf-8",
)
files.download("funasr_transcript.json")