dusty-nv / jetson-containers

Machine Learning Containers for NVIDIA Jetson and JetPack-L4T
MIT License
2.36k stars 481 forks source link

I can not set custom model for wyoming-whisper #671

Closed witold-gren closed 1 month ago

witold-gren commented 1 month ago

In original wyoming-whisper add-on in HA we have an ability to set custom model. We need just set model to custom and then in other field Custom model I can set custom model (like distil-whisper-large-v3-pl). I try to do it in few ways into this configuration but it don't work. I try to set two env params:

    environment:
      WHISPER_LANGUAGE: "pl"
      WHISPER_MODEL: "custom"
      WHISPER_CUSTOM_MODEL: "mmalyska/distil-whisper-large-v3-pl-ct2"

but then I see this error:

[21:39:19] INFO: Service exited with code 1 (by signal 0)
DEBUG:__main__:Namespace(model='null', uri='tcp://0.0.0.0:10300', data_dir=['/data'], download_dir='/data', device='cuda', language='pl', compute_type='default', beam_size=1, initial_prompt='', debug=True, log_format='%(levelname)s:%(name)s:%(message)s')
DEBUG:__main__:Loading null
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/dist-packages/wyoming_faster_whisper/__main__.py", line 155, in <module>
    run()
  File "/usr/local/lib/python3.11/dist-packages/wyoming_faster_whisper/__main__.py", line 150, in run
    asyncio.run(main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 188, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 120, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 650, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/wyoming_faster_whisper/__main__.py", line 124, in main
    whisper_model = faster_whisper.WhisperModel(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/faster_whisper/transcribe.py", line 127, in __init__
    model_path = download_model(
                 ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/faster_whisper/utils.py", line 77, in download_model
    raise ValueError(
ValueError: Invalid model size 'null', expected one of: tiny.en, tiny, base.en, base, small.en, small, medium.en, medium, large-v1, large-v2, large-v3, large, distil-large-v2, distil-medium.en, distil-small.en, distil-large-v3

Example how it works in original add-on:

image

How to correctly indicate my own model? In docs we can see that value custom is correct for model name: https://github.com/home-assistant/addons/blob/master/whisper/config.yaml#L22 Also we can find configuration for custom model https://github.com/home-assistant/addons/blob/master/whisper/config.yaml#L23

witold-gren commented 1 month ago

To use your own model, simply provide its link to HuggingFace in the WHISPER_MODEL variable. An example of how to set this in docker compose can be seen below:

x-shared-properties: &shared-properties
  runtime: nvidia                 # Use NVIDIA runtime
  init: false                     # Do not use init process
  restart: unless-stopped         # Restart policy
  network_mode: host              # Use host network mode, to auto-detect devices in network
  devices:
    - /dev/snd:/dev/snd           # to share audio devices
    - /dev/bus/usb                # to share usb devices

name: whisper-jetson
version: "3.9"
services:
  whisper:
    image: dustynv/wyoming-whisper:latest-r36.2.0
    <<: *shared-properties
    container_name: whisper
    hostname: whisper
    ports:
      - "10300:10300/tcp"
    volumes:
      - ./whisper/models/:/share/whisper
      - ./whisper/data/:/data
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    environment:
      WHISPER_LANGUAGE: "pl"
      WHISPER_MODEL: "WitoldG/distil-whisper-large-v3-pl-ct2"