utility updates

This commit is contained in:
zpeng11 2025-08-24 02:11:47 -04:00
parent 48d52778ce
commit 72c5d3224e
3 changed files with 23 additions and 1 deletions

2
.gitignore vendored
View File

@ -194,7 +194,9 @@ cython_debug/
# PyPI configuration file
.pypirc
#onnx
onnx/
*.onnx
tokenizer.json
output.wav
config.json

View File

@ -87,6 +87,25 @@ def export_bert_to_onnx(
else:
print("Warning: tokenizer.json not found")
# Copy config.json if it exists
if tokenizer_cache_dir and os.path.isdir(tokenizer_cache_dir):
config_json_path = os.path.join(tokenizer_cache_dir, "config.json")
else:
# For models from HuggingFace cache
cache_dir = os.path.expanduser("~/.cache/huggingface/transformers")
config_json_path = None
for root, dirs, files in os.walk(cache_dir):
if "config.json" in files and model_name.replace("/", "--") in root:
config_json_path = os.path.join(root, "config.json")
break
if config_json_path and os.path.exists(config_json_path):
dest_config_path = os.path.join(output_dir, "config.json")
shutil.copy2(config_json_path, dest_config_path)
print(f"Copied config.json to: {dest_config_path}")
else:
print("Warning: config.json not found")
print(f"Model exported successfully to: {output_dir}")
return combined_model, onnx_path

View File

@ -11,6 +11,7 @@ onnx
onnxruntime; platform_machine == "aarch64" or platform_machine == "arm64"
onnxruntime-gpu; platform_machine == "x86_64" or platform_machine == "AMD64"
onnxsim
onnxruntime-tools
tqdm
funasr==1.0.27
cn2an