Files
FunASR/web-pages/product-site/legacy/blog/punctuation-restoration-python.html
T
zhifu gaoandLauraGPT 84e049ed48 feat(site): launch the FunASR deployment product hub (#3424)
* docs: design product deployment hub

* docs(site): plan deployment product hub implementation

* feat(site): add deployment evidence registry

* feat(site): add deployment recommendation engine

* build(site): track reproducible live-site corpus

* feat(site): build bilingual deployment product surface

* feat(site): add deployment contracts and benchmarks

* feat(site): preserve legacy routes and unify navigation

* ci(site): validate reproducible product builds

* ops(site): add atomic releases and hardened nginx

* test(site): add responsive product browser coverage

* fix(site): support managed and manual nginx masters

* fix(site): make release smoke routes configurable

* docs(site): record product hub rollout

---------

Co-authored-by: LauraGPT <[email protected]>
2026-07-27 01:45:30 +08:00

136 lines
13 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>标点恢复(Punctuation Restoration)Python 实战:给无标点文本/ASR 结果自动加标点 | FunASR 博客</title>
<meta name="description" content="怎么给无标点的文本或语音识别结果自动加标点?FunASR ct-punc 是开源标点恢复模型,中英文双语,3 行 Python 补全 ,。?,英文还做句首大写;也能一行挂到 ASR 上。附真实实测输出。">
<meta name="keywords" content="标点恢复, 文本加标点, 标点预测, 标点符号恢复, punctuation restoration, add punctuation to text python, ct-punc, ASR 后处理, FunASR, 语音识别标点">
<link rel="icon" href="/logo.png">
<meta property="og:title" content="标点恢复(Punctuation Restoration)Python 实战:给无标点文本/ASR 结果自动加标点 | FunASR 博客">
<meta property="og:description" content="怎么给无标点的文本或语音识别结果自动加标点?FunASR ct-punc 是开源标点恢复模型,中英文双语,3 行 Python 补全 ,。?,英文还做句首大写;也能一行挂到 ASR 上。附真实实测输出。">
<meta property="og:type" content="article">
<meta property="og:url" content="https://www.funasr.com/blog/punctuation-restoration-python.html">
<meta property="og:image" content="https://www.funasr.com/logo.png">
<link rel="canonical" href="https://www.funasr.com/blog/punctuation-restoration-python.html">
<link rel="alternate" hreflang="en" href="https://www.funasr.com/en/blog/punctuation-restoration-python.html">
<link rel="alternate" hreflang="zh" href="https://www.funasr.com/blog/punctuation-restoration-python.html">
<link rel="alternate" hreflang="x-default" href="https://www.funasr.com/en/blog/punctuation-restoration-python.html">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","headline":"标点恢复(Punctuation Restoration)Python 实战:给无标点文本/ASR 结果自动加标点 | FunASR 博客","description":"怎么给无标点的文本或语音识别结果自动加标点?FunASR ct-punc 是开源标点恢复模型,中英文双语,3 行 Python 补全 ,。?,英文还做句首大写;也能一行挂到 ASR 上。附真实实测输出。","datePublished":"2026-06-23","dateModified":"2026-06-23","author":{"@type":"Organization","name":"FunASR / Tongyi Lab"},"publisher":{"@type":"Organization","name":"FunASR","logo":{"@type":"ImageObject","url":"https://www.funasr.com/logo.png"}},"mainEntityOfPage":{"@type":"WebPage","@id":"https://www.funasr.com/blog/punctuation-restoration-python.html"},"image":"https://www.funasr.com/logo.png"}
</script>
<style>:root{--primary:#2563eb;--primary-dark:#1d4ed8;--bg:#fff;--surface:#f8fafc;--border:#e2e8f0;--text:#0f172a;--text-soft:#475569;--text-muted:#94a3b8;--radius:12px}
*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Inter',-apple-system,sans-serif;color:var(--text);line-height:1.7}
a{color:var(--primary);text-decoration:none}a:hover{text-decoration:underline}
.container{max-width:800px;margin:0 auto;padding:0 24px}
.nav{position:fixed;top:0;left:0;right:0;z-index:100;background:rgba(255,255,255,0.9);backdrop-filter:blur(12px);border-bottom:1px solid var(--border);padding:14px 0}
.nav .container{max-width:1120px;display:flex;align-items:center;gap:24px}
.nav-logo{font-size:1.2rem;font-weight:800;color:var(--text)}.nav-logo span{color:var(--primary)}
.nav-links{display:flex;gap:20px;margin-left:auto;flex-wrap:wrap}
.nav-links a{font-size:0.85rem;font-weight:500;color:var(--text-soft)}
.nav-btn{padding:7px 16px;background:var(--primary);color:#fff;border-radius:7px;font-size:0.83rem;font-weight:600}
article{padding:120px 0 80px}
h1{font-size:2rem;font-weight:800;line-height:1.3;margin-bottom:14px}
h2{font-size:1.3rem;font-weight:700;margin:36px 0 14px;padding-top:16px;border-top:1px solid var(--border)}
h3{font-size:1.05rem;font-weight:700;margin:22px 0 10px}
p{margin-bottom:14px;color:var(--text-soft)}
ul,ol{margin:0 0 14px 22px;color:var(--text-soft)}li{margin-bottom:6px}
table{width:100%;border-collapse:collapse;margin:16px 0;font-size:0.86rem}
th,td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--border)}
th{font-weight:600;background:var(--surface);font-size:0.78rem;color:var(--text-muted)}
pre{background:#1e293b;color:#e2e8f0;padding:18px;border-radius:10px;overflow-x:auto;font-size:0.82rem;line-height:1.7;margin:14px 0}
code{font-family:ui-monospace,Menlo,monospace}
p code,li code{background:var(--surface);padding:2px 6px;border-radius:5px;font-size:0.85em;color:var(--primary-dark)}
.post-meta{color:var(--text-muted);font-size:0.85rem;margin-bottom:24px}
.cta{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px;margin:28px 0;text-align:center}
.cta a.btn{display:inline-block;padding:10px 24px;background:var(--primary);color:#fff;border-radius:8px;font-weight:600}
.post-list{list-style:none;margin:0;padding:0}
.post-list li{margin:0 0 8px}
.post-card{display:block;border:1px solid var(--border);border-radius:var(--radius);padding:20px 22px;margin-bottom:14px}
.post-card:hover{border-color:var(--primary);text-decoration:none}
.post-card h2{border:none;padding:0;margin:0 0 6px;font-size:1.15rem;color:var(--text)}
.post-card p{margin:0;color:var(--text-soft);font-size:0.9rem}
.post-card .date{color:var(--text-muted);font-size:0.8rem}
footer{background:#0f172a;color:#94a3b8;padding:28px 0;text-align:center;font-size:0.8rem}
footer a{color:#94a3b8}</style>
</head>
<body>
<nav class="nav"><div class="container"><a href="/" class="nav-logo">Fun<span>ASR</span></a><div class="nav-links"><a href="/#capabilities">核心能力</a><a href="/#usage">如何使用</a><a href="/#benchmark">性能</a><a href="/#demo">演示</a><a href="https://modelscope.github.io/FunASR/zh/" target="_blank">文档</a><a href="/quickstart.html">快速上手</a><a href="/models.html">模型</a><a href="/ecosystem.html">生态</a><a href="/blog/">技术博客</a><a href="/vs-whisper.html">对比 Whisper</a><a href="/donors.html">功德榜</a></div><a href="https://www.funasr.com/en/blog/punctuation-restoration-python.html" style="font-size:0.83rem;font-weight:500;color:var(--text-soft)">EN</a><a href="https://github.com/modelscope/FunASR" target="_blank" class="nav-btn">GitHub ★</a></div></nav>
<article><div class="container">
<h1>标点恢复(Punctuation Restoration)Python 实战:给无标点文本/ASR 结果自动加标点</h1>
<p class="post-meta">2026-06-23 · FunASR 团队</p>
<p>很多语音识别(ASR)模型输出的是<strong>没有标点</strong>的纯文本——一长串字读起来很费劲。<strong>标点恢复</strong>就是把"。"",""?"这些标点自动补回去,让转写结果可读。<strong>FunASR 的 <code>ct-punc</code></strong> 是一个开源的标点恢复模型,<strong>中英文都支持</strong>,3 行 Python 就能给任意文本加标点。下面全是真实实测输出。</p>
<h2>3 行代码做标点恢复(实测输出)</h2>
<pre>pip install funasr
from funasr import AutoModel
model = AutoModel(model="ct-punc", disable_update=True)
print(model.generate(input="我们都是木头人不许说话不许动")[0]["text"])
# 我们都是木头人,不许说话,不许动。</pre>
<p>输入是没有标点的连续文本,输出自动补上了逗号和句号。</p>
<h2>中英文真实示例</h2>
<table>
<tr><th>输入(无标点)</th><th>输出(ct-punc 加标点)</th></tr>
<tr><td>我们都是木头人不许说话不许动</td><td>我们都是木头人,不许说话,不许动。</td></tr>
<tr><td>今天天气怎么样我想出去走走你要一起吗</td><td>今天天气怎么样,我想出去走走,你要一起<strong>吗?</strong></td></tr>
<tr><td>the meeting is at 3 pm please bring your laptop and the report</td><td><strong>T</strong>he meeting is at 3 pm<strong>,</strong> please bring your laptop and the report<strong>.</strong></td></tr>
</table>
<p>可以看到:中文补「,。?」(问句还会自动判断用<strong>问号</strong>);英文补逗号、句号,还会把<strong>句首字母大写</strong>。同一个模型双语通吃。</p>
<h2>最常见用法:给 ASR 结果加标点</h2>
<p>标点恢复最大的用处是清洗语音识别的输出。FunASR 的 ASR 模型可以<strong>一行挂载</strong> ct-punc,识别完直接带标点:</p>
<pre>from funasr import AutoModel
# ASR + VAD + 标点,一次完成(以中文 Paraformer 为例)
model = AutoModel(model="paraformer-zh", vad_model="fsmn-vad", punc_model="ct-punc")
result = model.generate(input="audio.wav")
print(result[0]["text"]) # 输出已带标点</pre>
<p>当然你也可以像最上面那样<strong>单独</strong>用 ct-punc 处理任意文本——不限于语音,任何无标点文本(老字幕、OCR 结果、聊天记录)都能加标点。</p>
<h2>为什么用 ct-punc</h2>
<table>
<tr><th></th><th>ct-punc(FunASR)</th></tr>
<tr><td>语言</td><td>中文 + 英文(单模型双语)</td></tr>
<tr><td>用法</td><td>3 行 Python,输入文本即可;也能一行挂到 ASR 上</td></tr>
<tr><td>标点</td><td>,。?等;英文还做句首大写</td></tr>
<tr><td>许可证</td><td>开源,可商用</td></tr>
</table>
<p>想要完整的语音流程,看 <a href="/blog/chinese-speech-recognition.html">中文语音识别实战</a>、<a href="/blog/voice-activity-detection-python.html">VAD/去静音</a> 和 <a href="/blog/funasr-speaker-diarization.html">说话人分离</a>;不确定选哪个 ASR 模型看 <a href="/blog/which-funasr-model.html">模型选型指南</a>(默认推荐旗舰 Fun-ASR-Nano)。</p>
<div class="cta"><p><strong>FunASR 全家桶开源(MIT)</strong>——标点恢复、ASR、VAD、说话人、情感、LLM-ASR(旗舰 Fun-ASR-Nano),拿来即用。觉得有用就点个 Star 👇</p><p><a class="btn" href="https://github.com/modelscope/FunASR" target="_blank">⭐ Star FunASR</a></p><p style="margin-top:10px;font-size:0.85rem">也欢迎 Star:<a href="https://github.com/QwenAudio/SenseVoice" target="_blank">SenseVoice</a> · <a href="https://github.com/QwenAudio/Fun-ASR" target="_blank">Fun-ASR</a> · <a href="https://github.com/modelscope/FunClip" target="_blank">FunClip</a></p></div>
<!--related-posts-->
<h2>相关文章</h2>
<ul class="post-list">
<li><a href="/blog/funasr-vs-whisper-benchmark.html">FunASR vs Whisper 实测对比</a></li>
<li><a href="/blog/sensevoice-deployment-guide.html">SenseVoice 部署指南</a></li>
<li><a href="/blog/fun-asr-nano-guide.html">Fun-ASR-Nano 使用指南</a></li>
<li><a href="/blog/funasr-speaker-diarization.html">说话人分离:谁在何时说话</a></li>
<li><a href="/blog/sensevoice-emotion-language-detection.html">情感与语种检测</a></li>
<li><a href="/blog/funasr-realtime-streaming-asr.html">实时流式语音识别</a></li>
<li><a href="/blog/funasr-transcribe-long-audio.html">转写超长音频(1小时一次搞定)</a></li>
<li><a href="/blog/funasr-cli-transcribe-command-line.html">命令行转写(文本/JSON/SRT)</a></li>
<li><a href="/blog/self-hosted-openai-whisper-api-alternative.html">自托管 OpenAI Whisper API 替代</a></li>
<li><a href="/blog/generate-subtitles-srt-vtt-from-audio-video.html">自动生成字幕(SRT / VTT)</a></li>
<li><a href="/blog/speech-to-text-python-transcribe-audio.html">Python 语音转文字教程</a></li>
<li><a href="/blog/funasr-llama-cpp-whisper-cpp-alternative.html">FunASR 跑进 llama.cpp(whisper.cpp 替代)</a></li>
<li><a href="/blog/funasr-vs-faster-whisper-chinese.html">FunASR vs faster-whisper(中文/粤语)</a></li>
<li><a href="/blog/lightweight-speech-recognition-cpu.html">轻量语音识别(CPU 250MB)</a></li>
<li><a href="/blog/self-hosted-deepgram-assemblyai-alternative.html">自托管替代 Deepgram/AssemblyAI</a></li>
<li><a href="/blog/which-funasr-model.html">选哪个 FunASR 模型</a></li>
<li><a href="/blog/cantonese-speech-recognition.html">粤语语音识别(SenseVoice 原生粤语)</a></li>
<li><a href="/blog/japanese-speech-recognition.html">日语语音识别(SenseVoice 转写+标点+情感)</a></li>
<li><a href="/blog/voice-activity-detection-python.html">Python 语音活动检测(VAD)</a></li>
<li><a href="/blog/self-hosted-google-aws-azure-speech-to-text.html">自托管替代 Google/AWS/Azure 云语音 API</a></li>
<li><a href="/blog/chinese-speech-recognition.html">中文语音识别(普通话)实战</a></li>
<li><a href="/blog/speech-to-text-timestamps-python.html">语音识别带时间戳(字级)</a></li>
</ul>
</div></article>
<footer><div class="container">© 2024-2026 Tongyi Lab, Alibaba Group · <a href="https://github.com/modelscope/FunASR/blob/main/LICENSE">MIT License</a></div></footer>
</body>
</html>