mirror of
https://github.com/modelscope/FunASR.git
synced 2026-10-12 02:19:18 +00:00
deploy: c688455fce
This commit is contained in:
@@ -22923,7 +22923,7 @@
|
||||
else:
|
||||
print(f"You are using the latest version of funasr-{current_version}")
|
||||
</code></pre></details></div>
|
||||
<div class="api-detail" id="e455"><span class="dtag badge-f">function</span><h2><code>extract_language_from_asr_text(text)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L37" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Extract a SenseVoice language code before special tokens are removed.</p>
|
||||
<div class="api-detail" id="e455"><span class="dtag badge-f">function</span><h2><code>extract_language_from_asr_text(text)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L40" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Extract a SenseVoice language code before special tokens are removed.</p>
|
||||
</div><details class="src-block"><summary>📄 Source code</summary><pre><code>def extract_language_from_asr_text(text):
|
||||
"""Extract a SenseVoice language code before special tokens are removed."""
|
||||
if not isinstance(text, str):
|
||||
@@ -22931,7 +22931,7 @@
|
||||
match = _LANGUAGE_TAG_RE.search(text)
|
||||
return match.group(1) if match else None
|
||||
</code></pre></details></div>
|
||||
<div class="api-detail" id="e456"><span class="dtag badge-f">function</span><h2><code>resolve_transcription_language(requested_language, result)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L45" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Prefer the caller's language hint, then backend detection, else unknown.</p>
|
||||
<div class="api-detail" id="e456"><span class="dtag badge-f">function</span><h2><code>resolve_transcription_language(requested_language, result)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L48" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Prefer the caller's language hint, then backend detection, else unknown.</p>
|
||||
</div><details class="src-block"><summary>📄 Source code</summary><pre><code>def resolve_transcription_language(requested_language, result):
|
||||
"""Prefer the caller's language hint, then backend detection, else unknown."""
|
||||
if requested_language and requested_language.strip().lower() != "auto":
|
||||
@@ -22941,7 +22941,7 @@
|
||||
return detected_language
|
||||
return "unknown"
|
||||
</code></pre></details></div>
|
||||
<div class="api-detail" id="e457"><span class="dtag badge-f">function</span><h2><code>build_openai_fallback_segments(text, duration, max_chars)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L91" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Build coarse timestamped segments when a backend returns text only.</p>
|
||||
<div class="api-detail" id="e457"><span class="dtag badge-f">function</span><h2><code>build_openai_fallback_segments(text, duration, max_chars)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L94" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Build coarse timestamped segments when a backend returns text only.</p>
|
||||
</div><details class="src-block"><summary>📄 Source code</summary><pre><code>def build_openai_fallback_segments(text: str, duration: float, max_chars: int = 80):
|
||||
"""Build coarse timestamped segments when a backend returns text only."""
|
||||
parts = _split_text_for_openai_segments(text, max_chars=max_chars)
|
||||
@@ -22966,7 +22966,7 @@
|
||||
|
||||
return segments
|
||||
</code></pre></details></div>
|
||||
<div class="api-detail" id="e458"><span class="dtag badge-f">function</span><h2><code>prepare_audio_for_inference(audio_data, sr, target_sr)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L116" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Return mono float32 audio at target_sr for ASR inference.</p>
|
||||
<div class="api-detail" id="e458"><span class="dtag badge-f">function</span><h2><code>prepare_audio_for_inference(audio_data, sr, target_sr)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L119" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Return mono float32 audio at target_sr for ASR inference.</p>
|
||||
</div><details class="src-block"><summary>📄 Source code</summary><pre><code>def prepare_audio_for_inference(audio_data, sr, target_sr=16000):
|
||||
"""Return mono float32 audio at target_sr for ASR inference."""
|
||||
audio_data = np.asarray(audio_data)
|
||||
@@ -22981,7 +22981,7 @@
|
||||
|
||||
return audio_data.astype(np.float32), sr
|
||||
</code></pre></details></div>
|
||||
<div class="api-detail" id="e459"><span class="dtag badge-f">function</span><h2><code>attach_speaker_labels(audio_data, sr, segments, speaker_model, device)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L131" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Run speaker diarization once and attach labels to timestamped segments.</p>
|
||||
<div class="api-detail" id="e459"><span class="dtag badge-f">function</span><h2><code>attach_speaker_labels(audio_data, sr, segments, speaker_model, device)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L134" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Run speaker diarization once and attach labels to timestamped segments.</p>
|
||||
</div><details class="src-block"><summary>📄 Source code</summary><pre><code>def attach_speaker_labels(audio_data, sr, segments, speaker_model, device):
|
||||
"""Run speaker diarization once and attach labels to timestamped segments."""
|
||||
if not segments:
|
||||
@@ -23012,8 +23012,8 @@
|
||||
speaker_results = speaker_model.generate(
|
||||
input=[chunk[2] for chunk in chunks], cache={}, is_final=True
|
||||
)
|
||||
</code></pre><a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L131" target="_blank" class="src-more">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e460"><span class="dtag badge-f">function</span><h2><code>build_openai_verbose_json(result, requested_language)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L189" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Build OpenAI-compatible verbose JSON while preserving FunASR extensions.</p>
|
||||
</code></pre><a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L134" target="_blank" class="src-more">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e460"><span class="dtag badge-f">function</span><h2><code>build_openai_verbose_json(result, requested_language)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L192" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Build OpenAI-compatible verbose JSON while preserving FunASR extensions.</p>
|
||||
</div><details class="src-block"><summary>📄 Source code</summary><pre><code>def build_openai_verbose_json(result, requested_language=None):
|
||||
"""Build OpenAI-compatible verbose JSON while preserving FunASR extensions."""
|
||||
segments = []
|
||||
@@ -23037,7 +23037,7 @@
|
||||
"segments": segments,
|
||||
}
|
||||
</code></pre></details></div>
|
||||
<div class="api-detail" id="e461"><span class="dtag badge-f">function</span><h2><code>create_app(device, preload_model, model_path, hub, spk_model, cors_origins)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L213" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>📄 Source code</summary><pre><code>def create_app(
|
||||
<div class="api-detail" id="e461"><span class="dtag badge-f">function</span><h2><code>create_app(device, preload_model, model_path, hub, spk_model, cors_origins)</code></h2><div class="dmod">funasr.bin._server_app · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L216" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>📄 Source code</summary><pre><code>def create_app(
|
||||
device: str = "cuda",
|
||||
preload_model: str = "auto",
|
||||
model_path: str = None,
|
||||
@@ -23067,7 +23067,7 @@
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=normalized_origins,
|
||||
</code></pre><a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L213" target="_blank" class="src-more">View full source on GitHub →</a></details></div>
|
||||
</code></pre><a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/_server_app.py#L216" target="_blank" class="src-more">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e462"><span class="dtag badge-f">function</span><h2><code>main_hydra(kwargs)</code></h2><div class="dmod">funasr.bin.compute_audio_cmvn · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/compute_audio_cmvn.py#L15" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Main hydra.</p>
|
||||
<h4>Args:</h4>
|
||||
<ul>
|
||||
@@ -23935,10 +23935,10 @@
|
||||
args = build_arg_parser().parse_args()
|
||||
asyncio.run(main(args))
|
||||
</code></pre></details></div>
|
||||
<div class="api-detail" id="e495"><span class="dtag badge-f">function</span><h2><code>server_version_label()</code></h2><div class="dmod">funasr.bin.server · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/server.py#L21" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>📄 Source code</summary><pre><code>def server_version_label():
|
||||
<div class="api-detail" id="e495"><span class="dtag badge-f">function</span><h2><code>server_version_label()</code></h2><div class="dmod">funasr.bin.server · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/server.py#L22" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>📄 Source code</summary><pre><code>def server_version_label():
|
||||
return f"FunASR Server v{PACKAGE_VERSION}"
|
||||
</code></pre></details></div>
|
||||
<div class="api-detail" id="e496"><span class="dtag badge-f">function</span><h2><code>build_parser()</code></h2><div class="dmod">funasr.bin.server · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/server.py#L25" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>📄 Source code</summary><pre><code>def build_parser():
|
||||
<div class="api-detail" id="e496"><span class="dtag badge-f">function</span><h2><code>build_parser()</code></h2><div class="dmod">funasr.bin.server · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/server.py#L26" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>📄 Source code</summary><pre><code>def build_parser():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="FunASR OpenAI-Compatible API Server",
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
@@ -23947,6 +23947,7 @@ Examples:
|
||||
funasr-server # Start with SenseVoice on GPU
|
||||
funasr-server --device cpu # Start on CPU
|
||||
funasr-server --model paraformer # Use Paraformer model
|
||||
funasr-server --model moss-transcribe-diarize --device cuda:0
|
||||
funasr-server --port 9000 # Custom port
|
||||
funasr-server --model-path /path/to/local/model # Use local model
|
||||
funasr-server --model-path username/model --hub hf # Use HuggingFace model
|
||||
@@ -23961,15 +23962,14 @@ Then use with OpenAI SDK:
|
||||
parser.add_argument("--host", default="0.0.0.0", help="Bind address (default: 0.0.0.0)")
|
||||
parser.add_argument("--port", type=int, default=8000, help="Port (default: 8000)")
|
||||
parser.add_argument("--device", default="cuda", help="Device: cuda, cpu, mps (default: cuda)")
|
||||
parser.add_argument("--model", default="auto", help="Pre-load model: auto (GPU=fun-asr-nano, CPU=sensevoice), sensevoice, paraformer, fun-asr-nano")
|
||||
parser.add_argument("--model-path", default=None, help="Local model path or model ID (overrides --model)")
|
||||
parser.add_argument("--hub", default="ms", help="Model hub: ms (ModelScope), hf (HuggingFace) (default: ms)")
|
||||
parser.add_argument(
|
||||
"--spk-model",
|
||||
default="cam++",
|
||||
help="Speaker model loaded on the first spk=true request (default: cam++)",
|
||||
</code></pre><a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/server.py#L25" target="_blank" class="src-more">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e497"><span class="dtag badge-f">function</span><h2><code>main()</code></h2><div class="dmod">funasr.bin.server · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/server.py#L66" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>📄 Source code</summary><pre><code>def main():
|
||||
"--model",
|
||||
default="auto",
|
||||
help=(
|
||||
"Pre-load model: auto (GPU=fun-asr-nano, CPU=sensevoice), "
|
||||
"sensevoice, paraformer, fun-asr-nano, moss-transcribe-diarize"
|
||||
</code></pre><a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/server.py#L26" target="_blank" class="src-more">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e497"><span class="dtag badge-f">function</span><h2><code>main()</code></h2><div class="dmod">funasr.bin.server · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/server.py#L75" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p class="muted">No documentation yet.</p></div><details class="src-block"><summary>📄 Source code</summary><pre><code>def main():
|
||||
args = build_parser().parse_args()
|
||||
|
||||
try:
|
||||
@@ -23999,7 +23999,7 @@ Then use with OpenAI SDK:
|
||||
print(f"╔══════════════════════════════════════════════╗")
|
||||
print(f"║ {server_version_label():<44}║")
|
||||
print(f"║ Device: {args.device:<8} ║")
|
||||
</code></pre><a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/server.py#L66" target="_blank" class="src-more">View full source on GitHub →</a></details></div>
|
||||
</code></pre><a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/server.py#L75" target="_blank" class="src-more">View full source on GitHub →</a></details></div>
|
||||
<div class="api-detail" id="e498"><span class="dtag badge-f">function</span><h2><code>field2slice(field)</code></h2><div class="dmod">funasr.bin.tokenize_text · <a href="https://github.com/modelscope/FunASR/blob/main/funasr/bin/tokenize_text.py#L23" target="_blank">View on GitHub ↗</a></div><div class="ddoc"><p>Convert field string to slice</p>
|
||||
<p>Note that field string accepts 1-based integer.</p>
|
||||
<h4>Examples:</h4>
|
||||
|
||||
Reference in New Issue
Block a user