Skip to content

Commit ce31b33

Browse files
Merge pull request #27 from google-ai-edge:add-test-scripts
PiperOrigin-RevId: 916848561
2 parents 34f4b34 + 552ec66 commit ce31b33

2 files changed

Lines changed: 242 additions & 0 deletions

File tree

examples/models/parakeet.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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"

examples/models/whisper_tiny.sh

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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 Whisper-Tiny 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 "whisper_tiny" "Whisper-Tiny ASR Demo Script"
24+
25+
# --- 1. Download Whisper-Tiny model ---
26+
run_case "Download: Whisper-Tiny from HuggingFace" \
27+
litert download litert-community/whisper-tiny --file "whisper_tiny_30s_f32.tflite" --output "models/whisper_tiny"
28+
29+
# Verify the downloaded model exists
30+
WHISPER_TFLITE="models/whisper_tiny/whisper_tiny_30s_f32.tflite"
31+
if [ ! -f "$WHISPER_TFLITE" ]; then
32+
echo -e "${RED}Error: Downloaded model not found at $WHISPER_TFLITE${NC}"
33+
exit 1
34+
fi
35+
36+
# --- 2. Quantize the Whisper-Tiny model ---
37+
run_case "Quantize: Whisper-Tiny Dynamic Range INT8" \
38+
litert quantize "$WHISPER_TFLITE" --recipe dynamic_wi8_afp32 --output "models/whisper_tiny/whisper_tiny_30s_int8_dynamic.tflite"
39+
40+
run_case "Quantize: Whisper-Tiny Weight-Only INT8" \
41+
litert quantize "$WHISPER_TFLITE" --recipe weight_only_wi8_afp32 --output "models/whisper_tiny/whisper_tiny_30s_int8_weight_only.tflite"
42+
43+
# --- 3. Run Inference (Desktop & Android) ---
44+
run_case "Run: Whisper-Tiny FP32 on Desktop (CPU)" \
45+
litert run "$WHISPER_TFLITE" --desktop --cpu --iterations 1
46+
47+
if has_desktop_gpu "$WHISPER_TFLITE"; then
48+
run_case "Run: Whisper-Tiny FP32 on Desktop (GPU)" \
49+
litert run "$WHISPER_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: Whisper-Tiny Dynamic INT8 on Desktop (CPU)" \
55+
litert run "models/whisper_tiny/whisper_tiny_30s_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: Whisper-Tiny FP32 on Android (CPU)" \
60+
litert run "$WHISPER_TFLITE" --android --cpu --iterations 1
61+
62+
run_case "Run: Whisper-Tiny FP32 on Android (GPU)" \
63+
litert run "$WHISPER_TFLITE" --android --gpu --iterations 1
64+
65+
run_case "Run: Whisper-Tiny Dynamic INT8 on Android (CPU)" \
66+
litert run "models/whisper_tiny/whisper_tiny_30s_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+
run_case "Benchmark: Whisper-Tiny FP32 on Desktop (CPU) - Encode" \
73+
litert benchmark "$WHISPER_TFLITE" --desktop --cpu --signature-key "encode"
74+
75+
run_case "Benchmark: Whisper-Tiny FP32 on Desktop (CPU) - Decode" \
76+
litert benchmark "$WHISPER_TFLITE" --desktop --cpu --signature-key "decode"
77+
78+
if has_desktop_gpu "$WHISPER_TFLITE"; then
79+
run_case "Benchmark: Whisper-Tiny FP32 on Desktop (GPU) - Decode" \
80+
litert benchmark "$WHISPER_TFLITE" --desktop --gpu --signature-key "decode"
81+
fi
82+
83+
run_case "Benchmark: Whisper-Tiny Dynamic INT8 on Desktop (CPU) - Decode" \
84+
litert benchmark "models/whisper_tiny/whisper_tiny_30s_int8_dynamic.tflite" --desktop --cpu --signature-key "decode"
85+
86+
if has_android_device; then
87+
echo -e "\n${GREEN}Android device detected. Running Android benchmarks...${NC}"
88+
89+
run_case "Benchmark: Whisper-Tiny FP32 on Android (CPU) - Encode" \
90+
litert benchmark "$WHISPER_TFLITE" --android --cpu --signature-key "encode"
91+
92+
run_case "Benchmark: Whisper-Tiny FP32 on Android (CPU) - Decode" \
93+
litert benchmark "$WHISPER_TFLITE" --android --cpu --signature-key "decode"
94+
95+
run_case "Benchmark: Whisper-Tiny FP32 on Android (GPU) - Decode" \
96+
litert benchmark "$WHISPER_TFLITE" --android --gpu --signature-key "decode"
97+
98+
run_case "Benchmark: Whisper-Tiny Dynamic INT8 on Android - Decode" \
99+
litert benchmark "models/whisper_tiny/whisper_tiny_30s_int8_dynamic.tflite" --android --signature-key "decode"
100+
else
101+
echo -e "\n${YELLOW}No Android device detected. Skipping benchmarks on Android.${NC}"
102+
fi
103+
104+
# --- 5. Compile (AOT Compilation) ---
105+
if [[ "$(uname)" == "Linux" ]]; then
106+
run_case "Compile: Whisper-Tiny FP32 for Qualcomm sm8750 NPU" \
107+
litert compile "$WHISPER_TFLITE" --target sm8750 --output-dir "models/whisper_tiny"
108+
else
109+
echo -e "\n${YELLOW}Skipping offline AOT compilation on non-Linux platform ($(uname)).${NC}"
110+
fi
111+
112+
# --- 6. Visualize (Model Explorer) ---
113+
run_case "Visualize: Launch Model Explorer in the background" \
114+
litert visualize "$WHISPER_TFLITE"
115+
116+
run_case "Visualize: Stop all Model Explorer servers" \
117+
litert visualize --stop-all
118+
119+
# --- Summary Report ---
120+
print_summary_report "Whisper-Tiny"

0 commit comments

Comments
 (0)