diff --git a/api.html b/api.html index 2fbbea759..86e637bf4 100644 --- a/api.html +++ b/api.html @@ -23197,7 +23197,7 @@ res = model.generate(input=kwargs["input"]) print(res) -
No documentation yet.
class _BatchRequest:
+class_BatchRequest
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
class _BatchRequest:
def __init__(self, inputs, kwargs):
self.inputs = inputs
self.kwargs = kwargs
@@ -23206,7 +23206,7 @@
self.result = None
self.error = None
-classThreadSafeGenerateModel
funasr.bin.realtime_ws ยท View on GitHub โProtect mutable AutoModel runtime configuration across session threads.
+classThreadSafeGenerateModel
funasr.bin.realtime_ws ยท View on GitHub โProtect mutable AutoModel runtime configuration across session threads.
๐ Source code
class ThreadSafeGenerateModel:
"""Protect mutable AutoModel runtime configuration across session threads."""
@@ -23220,15 +23220,15 @@
def __getattr__(self, name):
return getattr(self.model, name)
-
Methods
.generate(*args, **kwargs) L57No documentation yet.
๐ Source
def generate(self, *args, **kwargs):
+
Methods
.generate(*args, **kwargs) L58No documentation yet.
๐ Source
def generate(self, *args, **kwargs):
with self.lock:
return self.model.generate(*args, **kwargs)
-methodThreadSafeGenerateModel.generate(*args, **kwargs)
funasr.bin.realtime_ws.ThreadSafeGenerateModel ยท View on GitHub โNo documentation yet.
๐ Source code
def generate(self, *args, **kwargs):
+methodThreadSafeGenerateModel.generate(*args, **kwargs)
funasr.bin.realtime_ws.ThreadSafeGenerateModel ยท View on GitHub โNo documentation yet.
๐ Source code
def generate(self, *args, **kwargs):
with self.lock:
return self.model.generate(*args, **kwargs)
-classRealtimeBatchingEngine
funasr.bin.realtime_ws ยท View on GitHub โSerialize the shared engine while batching compatible session requests.
+classRealtimeBatchingEngine
funasr.bin.realtime_ws ยท View on GitHub โSerialize the shared engine while batching compatible session requests.
๐ Source code
class RealtimeBatchingEngine:
"""Serialize the shared engine while batching compatible session requests."""
@@ -23259,7 +23259,7 @@
)
if isinstance(value, list):
return (
-
View full source on GitHub โMethods
.generate(inputs, **kwargs) L114No documentation yet.
Methods
.generate(inputs, **kwargs) L115No documentation yet.
๐ Source
def generate(self, inputs, **kwargs):
request_inputs = list(inputs) if isinstance(inputs, (list, tuple)) else [inputs]
if not request_inputs:
return []
@@ -23280,7 +23280,7 @@
raise request.error
return request.result
-methodRealtimeBatchingEngine.generate(inputs, **kwargs)
funasr.bin.realtime_ws.RealtimeBatchingEngine ยท View on GitHub โNo documentation yet.
๐ Source code
def generate(self, inputs, **kwargs):
+methodRealtimeBatchingEngine.generate(inputs, **kwargs)
funasr.bin.realtime_ws.RealtimeBatchingEngine ยท View on GitHub โNo documentation yet.
๐ Source code
def generate(self, inputs, **kwargs):
request_inputs = list(inputs) if isinstance(inputs, (list, tuple)) else [inputs]
if not request_inputs:
return []
@@ -23301,7 +23301,7 @@
raise request.error
return request.result
-functiondetect_and_fix_hallucination(text, max_ngram_length, max_occurrences)
funasr.bin.realtime_ws ยท View on GitHub โDetect repeated patterns (hallucination) and truncate to keep one occurrence.
+functiondetect_and_fix_hallucination(text, max_ngram_length, max_occurrences)
funasr.bin.realtime_ws ยท View on GitHub โDetect repeated patterns (hallucination) and truncate to keep one occurrence.
๐ Source code
def detect_and_fix_hallucination(text, max_ngram_length=12, max_occurrences=3):
"""Detect repeated patterns (hallucination) and truncate to keep one occurrence."""
if not text or len(text) < max_ngram_length * 2:
@@ -23332,8 +23332,8 @@
continue
count += 1
return count
-
View full source on GitHub โ
-classClientEndpointVAD
funasr.bin.realtime_ws ยท View on GitHub โTrack an utterance start without loading or running a VAD model.
+View full source on GitHub โ
+classClientEndpointVAD
funasr.bin.realtime_ws ยท View on GitHub โTrack an utterance start without loading or running a VAD model.
๐ Source code
class ClientEndpointVAD:
"""Track an utterance start without loading or running a VAD model."""
@@ -23346,20 +23346,20 @@
def reset(self):
self.current_speech_start = None
-
Methods
.start_utterance(start_ms) L443No documentation yet.
๐ Source
def start_utterance(self, start_ms):
+
Methods
.start_utterance(start_ms) L444No documentation yet.
๐ Source
def start_utterance(self, start_ms):
if self.current_speech_start is None:
self.current_speech_start = start_ms
-
-methodClientEndpointVAD.start_utterance(start_ms)
funasr.bin.realtime_ws.ClientEndpointVAD ยท View on GitHub โNo documentation yet.
๐ Source code
def start_utterance(self, start_ms):
+methodClientEndpointVAD.start_utterance(start_ms)
funasr.bin.realtime_ws.ClientEndpointVAD ยท View on GitHub โNo documentation yet.
๐ Source code
def start_utterance(self, start_ms):
if self.current_speech_start is None:
self.current_speech_start = start_ms
-methodClientEndpointVAD.reset()
funasr.bin.realtime_ws.ClientEndpointVAD ยท View on GitHub โNo documentation yet.
๐ Source code
def reset(self):
+methodClientEndpointVAD.reset()
funasr.bin.realtime_ws.ClientEndpointVAD ยท View on GitHub โNo documentation yet.
๐ Source code
def reset(self):
self.current_speech_start = None
-classHybridSpeakerTracker
funasr.bin.realtime_ws ยท View on GitHub โSpeaker diarization: streaming ClusterBackend + final re-clustering.
+classHybridSpeakerTracker
funasr.bin.realtime_ws ยท View on GitHub โSpeaker diarization: streaming ClusterBackend + final re-clustering.
๐ Source code
class HybridSpeakerTracker:
"""Speaker diarization: streaming ClusterBackend + final re-clustering."""
@@ -23390,7 +23390,7 @@
self.all_chunks = deque(maxlen=max_history_chunks)
self.all_embeddings = deque(maxlen=max_history_chunks)
self.last_speaker_id = 0
-
View full source on GitHub โMethods
.assign_streaming(audio_samples, seg_start_s, seg_end_s, sentence) L483Assign speaker ID during streaming using ClusterBackend.
+View full source on GitHub โMethods
.assign_streaming(audio_samples, seg_start_s, seg_end_s, sentence) L484Assign speaker ID during streaming using ClusterBackend.
๐ Source
def assign_streaming(self, audio_samples, seg_start_s, seg_end_s, sentence):
"""Assign speaker ID during streaming using ClusterBackend."""
vad_seg = [[seg_start_s, seg_end_s, audio_samples]]
@@ -23413,7 +23413,7 @@
self.distribute_spk(temp, sv_output)
sentence["spk"] = temp[0].get("spk", self.last_speaker_id)
self.last_speaker_id = sentence["spk"]
-
.finalize(sentences, min_split_s) L573Final re-clustering for accurate speaker assignment.
+.finalize(sentences, min_split_s) L574Final re-clustering for accurate speaker assignment.
๐ Source
def finalize(self, sentences, min_split_s=3.0):
"""Final re-clustering for accurate speaker assignment."""
if not self.all_embeddings or not sentences:
@@ -23444,13 +23444,13 @@
prefix.update(text=prefix_text, end=history_start_ms)
final_sentences.append(prefix)
current.update(
-
View full source โ.reset() L668No documentation yet.
๐ Source
def reset(self):
self.speaker_centers = []
self.speaker_center_updates = []
self.all_chunks.clear()
self.all_embeddings.clear()
self.last_speaker_id = 0
-
.session_stats() L675No documentation yet.
๐ Source
def session_stats(self):
return {
"speaker_history_chunks": len(self.all_chunks),
"speaker_history_embeddings": len(self.all_embeddings),
@@ -23460,7 +23460,7 @@
"last_speaker_id": self.last_speaker_id,
}
-methodHybridSpeakerTracker.assign_streaming(audio_samples, seg_start_s, seg_end_s, sentence)
funasr.bin.realtime_ws.HybridSpeakerTracker ยท View on GitHub โAssign speaker ID during streaming using ClusterBackend.
+methodHybridSpeakerTracker.assign_streaming(audio_samples, seg_start_s, seg_end_s, sentence)
funasr.bin.realtime_ws.HybridSpeakerTracker ยท View on GitHub โAssign speaker ID during streaming using ClusterBackend.
๐ Source code
def assign_streaming(self, audio_samples, seg_start_s, seg_end_s, sentence):
"""Assign speaker ID during streaming using ClusterBackend."""
vad_seg = [[seg_start_s, seg_end_s, audio_samples]]
@@ -23484,7 +23484,7 @@
sentence["spk"] = temp[0].get("spk", self.last_speaker_id)
self.last_speaker_id = sentence["spk"]
-methodHybridSpeakerTracker.finalize(sentences, min_split_s)
funasr.bin.realtime_ws.HybridSpeakerTracker ยท View on GitHub โFinal re-clustering for accurate speaker assignment.
+methodHybridSpeakerTracker.finalize(sentences, min_split_s)
funasr.bin.realtime_ws.HybridSpeakerTracker ยท View on GitHub โFinal re-clustering for accurate speaker assignment.
๐ Source code
def finalize(self, sentences, min_split_s=3.0):
"""Final re-clustering for accurate speaker assignment."""
if not self.all_embeddings or not sentences:
@@ -23515,15 +23515,15 @@
prefix.update(text=prefix_text, end=history_start_ms)
final_sentences.append(prefix)
current.update(
-
View full source on GitHub โ
-methodHybridSpeakerTracker.reset()
funasr.bin.realtime_ws.HybridSpeakerTracker ยท View on GitHub โNo documentation yet.
+methodHybridSpeakerTracker.reset()
funasr.bin.realtime_ws.HybridSpeakerTracker ยท View on GitHub โNo documentation yet.
๐ Source code
def reset(self):
self.speaker_centers = []
self.speaker_center_updates = []
self.all_chunks.clear()
self.all_embeddings.clear()
self.last_speaker_id = 0
-methodHybridSpeakerTracker.session_stats()
funasr.bin.realtime_ws.HybridSpeakerTracker ยท View on GitHub โNo documentation yet.
๐ Source code
def session_stats(self):
+methodHybridSpeakerTracker.session_stats()
funasr.bin.realtime_ws.HybridSpeakerTracker ยท View on GitHub โNo documentation yet.
๐ Source code
def session_stats(self):
return {
"speaker_history_chunks": len(self.all_chunks),
"speaker_history_embeddings": len(self.all_embeddings),
@@ -23533,7 +23533,7 @@
"last_speaker_id": self.last_speaker_id,
}
-classRealtimeASRSession
funasr.bin.realtime_ws ยท View on GitHub โManages a single streaming ASR session.
+classRealtimeASRSession
funasr.bin.realtime_ws ยท View on GitHub โManages a single streaming ASR session.
๐ Source code
class RealtimeASRSession:
"""Manages a single streaming ASR session."""
@@ -23564,7 +23564,7 @@
# length-L segment. Under concurrency that saturates the GPU and long-segment
# requests time out. Capping the partial window to the most recent
# `partial_window_sec` seconds makes interim re-decoding ~O(L) per segment
-
View full source on GitHub โMethods
.add_audio(pcm_bytes) L745No documentation yet.
Methods
.add_audio(pcm_bytes) L746No documentation yet.
๐ Source
def add_audio(self, pcm_bytes):
audio_int16 = np.frombuffer(pcm_bytes, dtype=np.int16)
audio_float = audio_int16.astype(np.float32) / 32768.0
chunk_start_sample = self.total_samples
@@ -23589,10 +23589,10 @@
logger.info(f"Locked: [{seg[0]}-{seg[1]}ms] \"{seg_text[:40]}\"")
self._compact_audio_buffer()
-
.should_decode() L880No documentation yet.
๐ Source
def should_decode(self):
threshold = self.first_chunk_samples if not self.first_decode_done else self.chunk_samples
return (self.total_samples - self.last_decode_samples) >= threshold
-
.decode(is_final) L885No documentation yet.
๐ Source
def decode(self, is_final=False):
if is_final and self.endpoint_mode == "client":
return self.commit()
@@ -23622,7 +23622,7 @@
if len(seg_audio) < self.chunk_samples // 2:
return self._build_response(is_final)
-
View full source โ.commit() L952Finalize one client-delimited utterance while keeping the session open.
+View full source โ.commit() L953Finalize one client-delimited utterance while keeping the session open.
๐ Source
def commit(self):
"""Finalize one client-delimited utterance while keeping the session open."""
if self.endpoint_mode != "client":
@@ -23640,7 +23640,7 @@
response = self._build_response(is_final=True)
self._reset_utterance_state()
return response
-
.get_partial_decode_audio() L1015Return the bounded audio window used for unstable partial decoding.
+.get_partial_decode_audio() L1016Return the bounded audio window used for unstable partial decoding.
๐ Source
def get_partial_decode_audio(self):
"""Return the bounded audio window used for unstable partial decoding."""
seg_start_sample = int(self.vad.current_speech_start * self.sample_rate / 1000)
@@ -23654,7 +23654,7 @@
decode_start_sample = max(self.audio_buffer_start_sample, decode_start_sample)
start_ms = int(decode_start_sample * 1000 / self.sample_rate)
return self._slice_audio(decode_start_sample, self.total_samples), start_ms
-
.session_stats() L1282No documentation yet.
๐ Source
def session_stats(self):
stats = {
"duration_ms": int(self.total_samples * 1000 / self.sample_rate),
"total_samples": self.total_samples,
@@ -23669,7 +23669,7 @@
if self.spk_tracker:
stats.update(self.spk_tracker.session_stats())
return stats
-
.reset() L1298No documentation yet.
๐ Source
def reset(self):
self.audio_buffer = np.array([], dtype=np.float32)
self.audio_buffer_start_sample = 0
self.total_samples = 0
@@ -23686,7 +23686,7 @@
if self.spk_tracker:
self.spk_tracker.reset()
-methodRealtimeASRSession.add_audio(pcm_bytes)
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โNo documentation yet.
๐ Source code
def add_audio(self, pcm_bytes):
+methodRealtimeASRSession.add_audio(pcm_bytes)
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โNo documentation yet.
๐ Source code
def add_audio(self, pcm_bytes):
audio_int16 = np.frombuffer(pcm_bytes, dtype=np.int16)
audio_float = audio_int16.astype(np.float32) / 32768.0
chunk_start_sample = self.total_samples
@@ -23712,11 +23712,11 @@
self._compact_audio_buffer()
-methodRealtimeASRSession.should_decode()
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โNo documentation yet.
๐ Source code
def should_decode(self):
+methodRealtimeASRSession.should_decode()
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โNo documentation yet.
๐ Source code
def should_decode(self):
threshold = self.first_chunk_samples if not self.first_decode_done else self.chunk_samples
return (self.total_samples - self.last_decode_samples) >= threshold
-methodRealtimeASRSession.decode(is_final)
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โNo documentation yet.
๐ Source code
def decode(self, is_final=False):
+methodRealtimeASRSession.decode(is_final)
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โNo documentation yet.
๐ Source code
def decode(self, is_final=False):
if is_final and self.endpoint_mode == "client":
return self.commit()
@@ -23746,8 +23746,8 @@
if len(seg_audio) < self.chunk_samples // 2:
return self._build_response(is_final)
-
View full source on GitHub โ
-methodRealtimeASRSession.commit()
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โFinalize one client-delimited utterance while keeping the session open.
+View full source on GitHub โ
+methodRealtimeASRSession.commit()
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โFinalize one client-delimited utterance while keeping the session open.
๐ Source code
def commit(self):
"""Finalize one client-delimited utterance while keeping the session open."""
if self.endpoint_mode != "client":
@@ -23766,7 +23766,7 @@
self._reset_utterance_state()
return response
-methodRealtimeASRSession.get_partial_decode_audio()
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โReturn the bounded audio window used for unstable partial decoding.
+methodRealtimeASRSession.get_partial_decode_audio()
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โReturn the bounded audio window used for unstable partial decoding.
๐ Source code
def get_partial_decode_audio(self):
"""Return the bounded audio window used for unstable partial decoding."""
seg_start_sample = int(self.vad.current_speech_start * self.sample_rate / 1000)
@@ -23781,7 +23781,7 @@
start_ms = int(decode_start_sample * 1000 / self.sample_rate)
return self._slice_audio(decode_start_sample, self.total_samples), start_ms
-methodRealtimeASRSession.session_stats()
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โNo documentation yet.
๐ Source code
def session_stats(self):
+methodRealtimeASRSession.session_stats()
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โNo documentation yet.
๐ Source code
def session_stats(self):
stats = {
"duration_ms": int(self.total_samples * 1000 / self.sample_rate),
"total_samples": self.total_samples,
@@ -23797,7 +23797,7 @@
stats.update(self.spk_tracker.session_stats())
return stats
-methodRealtimeASRSession.reset()
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โNo documentation yet.
๐ Source code
def reset(self):
+methodRealtimeASRSession.reset()
funasr.bin.realtime_ws.RealtimeASRSession ยท View on GitHub โNo documentation yet.
๐ Source code
def reset(self):
self.audio_buffer = np.array([], dtype=np.float32)
self.audio_buffer_start_sample = 0
self.total_samples = 0
@@ -23814,7 +23814,7 @@
if self.spk_tracker:
self.spk_tracker.reset()
-functionload_models(args)
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def load_models(args):
+functionload_models(args)
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def load_models(args):
global _vllm_engine, _asr_kwargs, _vad_model, _spk_model
if _vllm_engine is None:
from funasr import AutoModel
@@ -23844,13 +23844,13 @@
logger.info(f"Loaded {len(hotwords)} hotwords from '{hw_file}'")
if getattr(args, 'language', None):
-
View full source on GitHub โ
-functioncreate_speaker_tracker(spk_model, args)
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
+functioncreate_speaker_tracker(spk_model, args)
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def create_speaker_tracker(spk_model, args):
if not getattr(args, "enable_spk", False) or spk_model is None:
return None
return HybridSpeakerTracker(spk_model, args.device)
-functioncreate_vad(vad_model, args)
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def create_vad(vad_model, args):
+functioncreate_vad(vad_model, args)
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def create_vad(vad_model, args):
if getattr(args, "endpoint_mode", "server") == "client":
return ClientEndpointVAD()
@@ -23874,7 +23874,7 @@
setattr(session_model, name, session_config)
return DynamicStreamingVAD(session_model)
-functionlog_session_stats(session)
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def log_session_stats(session):
+functionlog_session_stats(session)
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def log_session_stats(session):
stats = session.session_stats()
logger.info(
"Session stats: duration_ms=%d audio_buffer_samples=%d "
@@ -23892,7 +23892,7 @@
)
return stats
-functionbuild_websocket_serve_kwargs(args)
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def build_websocket_serve_kwargs(args):
+functionbuild_websocket_serve_kwargs(args)
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def build_websocket_serve_kwargs(args):
return {
"max_size": args.ws_max_size,
"ping_interval": _positive_or_none(args.ws_ping_interval),
@@ -23900,7 +23900,7 @@
"close_timeout": args.ws_close_timeout,
}
-functionbuild_arg_parser()
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def build_arg_parser():
+functionbuild_arg_parser()
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def build_arg_parser():
parser = argparse.ArgumentParser(description="Fun-ASR-Nano Streaming WebSocket Server")
parser.add_argument("--port", type=int, default=10095)
parser.add_argument("--model", type=str, default="FunAudioLLM/Fun-ASR-Nano-2512")
@@ -23930,8 +23930,8 @@
parser.add_argument(
"--decode-max-batch-size",
type=int,
-
View full source on GitHub โ
-
+functioncli_main()
funasr.bin.realtime_ws ยท View on GitHub โNo documentation yet.
๐ Source code
def cli_main():
args = build_arg_parser().parse_args()
asyncio.run(main(args))