Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion models/convert-silero-vad-to-ggml.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def convert_silero_vad(output_path, print_tensors=True):
cleaned_dict[clean_key] = value

base, ext = os.path.splitext(output_path)
output_file = f"{base}-v{silero_version}-ggml{ext}"
output_file = f"ggml-{base}-v{silero_version}{ext}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ggml prefix should come before the file name and not before the path to the models directory:

Suggested change
output_file = f"ggml-{base}-v{silero_version}{ext}"
output_file = f"{base}ggml-v{silero_version}{ext}"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should perhaps change this to have a default value for the --output parameter, and then just allow it to be overridden by anything that the user wants. I'm not sure why I did not do that at the time.
Something like:

diff --git a/models/convert-silero-vad-to-ggml.py b/models/convert-silero-vad-to-ggml.py
index 9d3afd4c..b9fb549e 100644
--- a/models/convert-silero-vad-to-ggml.py
+++ b/models/convert-silero-vad-to-ggml.py
@@ -19,16 +19,15 @@ def convert_silero_vad(output_path, print_tensors=True):
                 clean_key = "_model." + key
             cleaned_dict[clean_key] = value
 
-    base, ext = os.path.splitext(output_path)
-    output_file = f"ggml-{base}-v{silero_version}{ext}"
-    print(f"Saving GGML Silero-VAD model to {output_file}")
+    print(f"Saving GGML Silero-VAD model to {output_path}")
 
     print("\nTensor info for debugging:")
     for key, tensor in cleaned_dict.items():
         print(f"  - {key}: {tensor.shape} ({tensor.dtype})")
     print()
 
-    with open(output_file, "wb") as fout:
+    print(f"output_file: {output_path}")
+    with open(output_path, "wb") as fout:
         # Write magic and version
         fout.write(struct.pack("i", 0x67676d6c))
 
@@ -184,12 +183,12 @@ def convert_silero_vad(output_path, print_tensors=True):
 
             print(f"  Wrote {data.size * (2 if ftype==1 else 4)} bytes")
 
-    print(f"\nDone! Model has been converted to GGML format: {output_file}")
-    print(f"File size: {os.path.getsize(output_file)} bytes")
+    print(f"\nDone! Model has been converted to GGML format: {output_path}")
+    print(f"File size: {os.path.getsize(output_path)} bytes")
 
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(description="Convert Silero-VAD PyTorch model to GGML format")
-    parser.add_argument("--output", type=str, required=True, help="Path to output GGML model file")
+    parser.add_argument("--output", type=str, default=f"models/ggml-v{silero_version}.bin", help="Path to output GGML model file")
     parser.add_argument("--print-tensors", action="store_true", help="Print tensor values", default=True)
     args = parser.parse_args()

This would allow the conversion to be run as:

(venv) $ python models/convert-silero-vad-to-ggml.py
Saving GGML Silero-VAD model to models/ggml-v5.1.2.bin
...

print(f"Saving GGML Silero-VAD model to {output_file}")

print("\nTensor info for debugging:")
Expand Down