add_meta_data.py
980 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
# Copyright 2025 Xiaomi Corp. (authors: Fangjun Kuang)
import onnx
def main():
meta_data = {
"model_type": "t-one",
"language": "Russian",
"version": 1,
"maintainer": "k2-fsa",
"sample_rate": 8000,
"frame_length_ms": 300, # chunk_duration_ms
"state_dim": 219729,
"comment": "This is a streaming CTC model for Russian with expected audio sample rate 8000",
"url": "https://github.com/voicekit-team/T-one",
"see_also": "https://huggingface.co/t-tech/T-one",
}
model = onnx.load("./model.onnx")
while len(model.metadata_props):
model.metadata_props.pop()
for key, value in meta_data.items():
meta = model.metadata_props.add()
meta.key = key
meta.value = str(value)
print("--------------------")
print(model.metadata_props)
onnx.save(model, "./model.onnx")
if __name__ == "__main__":
main()