1+ #! /bin/bash
2+ # Copyright 2026 The LiteRT CLI Authors.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ # ==============================================================================
16+
17+ # LiteRT CLI Parakeet-TDT Demo & Test Script
18+ set -e
19+
20+ # Source shared utilities relative to script
21+ source " $( dirname " ${BASH_SOURCE[0]} " ) /../utils.sh"
22+
23+ setup_test_env " parakeet_tdt" " Parakeet-TDT ASR Demo Script"
24+
25+ # --- 1. Download Parakeet-TDT model ---
26+ run_case " Download: Parakeet-TDT from HuggingFace" \
27+ litert download litert-community/parakeet-tdt-0.6b-v3 --file " parakeet_tdt_0.6b_v3_5s_f32.tflite" --output " models/parakeet_tdt"
28+
29+ # Verify the downloaded model exists
30+ PARAKEET_TFLITE=" models/parakeet_tdt/parakeet_tdt_0.6b_v3_5s_f32.tflite"
31+ if [ ! -f " $PARAKEET_TFLITE " ]; then
32+ echo -e " ${RED} Error: Downloaded model not found at $PARAKEET_TFLITE ${NC} "
33+ exit 1
34+ fi
35+
36+ # --- 2. Quantize the Parakeet-TDT model ---
37+ run_case " Quantize: Parakeet-TDT Dynamic Range INT8" \
38+ litert quantize " $PARAKEET_TFLITE " --recipe dynamic_wi8_afp32 --output " models/parakeet_tdt/parakeet_tdt_0.6b_v3_5s_int8_dynamic.tflite"
39+
40+ run_case " Quantize: Parakeet-TDT Weight-Only INT8" \
41+ litert quantize " $PARAKEET_TFLITE " --recipe weight_only_wi8_afp32 --output " models/parakeet_tdt/parakeet_tdt_0.6b_v3_5s_int8_weight_only.tflite"
42+
43+ # --- 3. Run Inference (Desktop & Android) ---
44+ run_case " Run: Parakeet-TDT FP32 on Desktop (CPU)" \
45+ litert run " $PARAKEET_TFLITE " --desktop --cpu --iterations 1
46+
47+ if has_desktop_gpu " $PARAKEET_TFLITE " ; then
48+ run_case " Run: Parakeet-TDT FP32 on Desktop (GPU)" \
49+ litert run " $PARAKEET_TFLITE " --desktop --gpu --iterations 1
50+ else
51+ echo -e " \n${YELLOW} Desktop GPU delegate is not supported. Skipping Desktop GPU run.${NC} "
52+ fi
53+
54+ run_case " Run: Parakeet-TDT Dynamic INT8 on Desktop (CPU)" \
55+ litert run " models/parakeet_tdt/parakeet_tdt_0.6b_v3_5s_int8_dynamic.tflite" --desktop --cpu --iterations 1
56+
57+ if has_android_device; then
58+ echo -e " \n${GREEN} Android device detected. Running Android inference...${NC} "
59+ run_case " Run: Parakeet-TDT FP32 on Android (CPU)" \
60+ litert run " $PARAKEET_TFLITE " --android --cpu --iterations 1
61+
62+ run_case " Run: Parakeet-TDT FP32 on Android (GPU)" \
63+ litert run " $PARAKEET_TFLITE " --android --gpu --iterations 1
64+
65+ run_case " Run: Parakeet-TDT Dynamic INT8 on Android (CPU)" \
66+ litert run " models/parakeet_tdt/parakeet_tdt_0.6b_v3_5s_int8_dynamic.tflite" --android --cpu --iterations 1
67+ fi
68+
69+ # --- 4. Benchmark (Desktop & Android) ---
70+ echo -e " \n${GREEN} Running Desktop benchmarks...${NC} "
71+
72+ # Desktop Benchmarks
73+ run_case " Benchmark: Parakeet-TDT FP32 on Desktop (CPU) - Encode" \
74+ litert benchmark " $PARAKEET_TFLITE " --desktop --cpu --signature-key " encode"
75+
76+ run_case " Benchmark: Parakeet-TDT FP32 on Desktop (CPU) - Decode" \
77+ litert benchmark " $PARAKEET_TFLITE " --desktop --cpu --signature-key " decode"
78+
79+ if has_desktop_gpu " $PARAKEET_TFLITE " ; then
80+ run_case " Benchmark: Parakeet-TDT FP32 on Desktop (GPU) - Decode" \
81+ litert benchmark " $PARAKEET_TFLITE " --desktop --gpu --signature-key " decode"
82+ fi
83+
84+ run_case " Benchmark: Parakeet-TDT Dynamic INT8 on Desktop (CPU) - Decode" \
85+ litert benchmark " models/parakeet_tdt/parakeet_tdt_0.6b_v3_5s_int8_dynamic.tflite" --desktop --cpu --signature-key " decode"
86+
87+ # Android Benchmarks
88+ if has_android_device; then
89+ echo -e " \n${GREEN} Android device detected. Running Android benchmarks...${NC} "
90+
91+ run_case " Benchmark: Parakeet-TDT FP32 on Android (CPU) - Encode" \
92+ litert benchmark " $PARAKEET_TFLITE " --android --cpu --signature-key " encode"
93+
94+ run_case " Benchmark: Parakeet-TDT FP32 on Android (CPU) - Decode" \
95+ litert benchmark " $PARAKEET_TFLITE " --android --cpu --signature-key " decode"
96+
97+ run_case " Benchmark: Parakeet-TDT FP32 on Android (GPU) - Decode" \
98+ litert benchmark " $PARAKEET_TFLITE " --android --gpu --signature-key " decode"
99+
100+ run_case " Benchmark: Parakeet-TDT Dynamic INT8 on Android - Decode" \
101+ litert benchmark " models/parakeet_tdt/parakeet_tdt_0.6b_v3_5s_int8_dynamic.tflite" --android --signature-key " decode"
102+ else
103+ echo -e " \n${YELLOW} No Android device detected. Skipping benchmarks on Android.${NC} "
104+ fi
105+
106+ # --- 5. Compile (AOT Compilation) ---
107+ if [[ " $( uname) " == " Linux" ]]; then
108+ run_case " Compile: Parakeet-TDT FP32 for Qualcomm sm8750 NPU" \
109+ litert compile " $PARAKEET_TFLITE " --target sm8750 --output-dir " models/parakeet_tdt"
110+ else
111+ echo -e " \n${YELLOW} Skipping offline AOT compilation on non-Linux platform ($( uname) ).${NC} "
112+ fi
113+
114+ # --- 6. Visualize (Model Explorer) ---
115+ run_case " Visualize: Launch Model Explorer in the background" \
116+ litert visualize " $PARAKEET_TFLITE "
117+
118+ run_case " Visualize: Stop all Model Explorer servers" \
119+ litert visualize --stop-all
120+
121+ # --- Summary Report ---
122+ print_summary_report " Parakeet-TDT"
0 commit comments