MCPcopy Index your code
hub / github.com/FunAudioLLM/Fun-ASR / print_result

Function print_result

client_python.py:51–86  ·  view source on GitHub ↗

Print ASR result to terminal.

(data, show_spk=True)

Source from the content-addressed store, hash-verified

49
50
51def print_result(data, show_spk=True):
52 """Print ASR result to terminal."""
53 sentences = data.get("sentences", [])
54 partial = data.get("partial", "")
55 partial_start = data.get("partial_start_ms", 0)
56 is_final = data.get("is_final", False)
57
58 sys.stdout.write("\033[2J\033[H")
59
60 print(f"{GREEN}Fun-ASR-Nano Streaming ASR{RESET}")
61 print(f"{GRAY}{'─' * 60}{RESET}")
62
63 for s in sentences:
64 start = s.get("start", s.get("start_ms", 0))
65 end = s.get("end", s.get("end_ms", 0))
66 spk = s.get("spk", -1)
67 text = s["text"]
68
69 time_str = f"{GRAY}[{format_time(start)}-{format_time(end)}]{RESET}"
70 spk_str = ""
71 if show_spk and spk >= 0:
72 color = SPK_COLORS[spk % len(SPK_COLORS)]
73 spk_str = f" {color}SPK{spk}{RESET}"
74
75 print(f" {time_str}{spk_str} {text}")
76
77 if partial:
78 print(f" {GRAY}[{format_time(partial_start)}-...] {partial}{RESET}")
79
80 if is_final:
81 print(f"\n{GRAY}{'─' * 60}{RESET}")
82 print(f"{GREEN}Done.{RESET} {len(sentences)} sentences")
83 else:
84 print(f"\n{GRAY}Recording... Press Ctrl+C to stop{RESET}")
85
86 sys.stdout.flush()
87
88
89async def run_mic(args):

Callers 2

recv_resultsFunction · 0.85
run_micFunction · 0.85

Calls 1

format_timeFunction · 0.85

Tested by

no test coverage detected