Skip to content

fix: import sounddevice lazily so library use doesn't need PortAudio #63

Open

Description

@StuBehan

import stackvox (even just from stackvox import normalize_for_speech) fails on a machine without PortAudio:

OSError: PortAudio library not found

stackvox.engine imports sounddevice at module level, but only the playback paths (speak, _stream_play) use it. Servers and headless hosts that only want synthesize() or the text helpers currently have to install system audio libraries, or stub the module (sys.modules["sounddevice"] = types.ModuleType("sounddevice")) before importing.

Proposal

Import sounddevice inside the playback methods instead of at module level (optionally also move it to a playback extra).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions