Skip to content

(Community project) Pythonic and strongly-typed wrappers for audio.cpp #253

Description

@Tremeschin

Hey! thought sharing for linking on the community projects readme section that I'm writing strongly typed python wrapper classes for audio.cpp in my multimodal package named delusion 😅 (fast imports, caching, pythonic use, model downloads, tempfile)1.

It's basically a place that I'm centralizing curated models tweaked and abstracted to my needs, with extra utilities.


Motivation is that, while I agree dependency hell exists in python + portability and hardware accelerator issues per your goals, a pure terminal usage may require too much files and models micro-management, arguments validation, skimming through documentation for relevant information, or untyped subprocess calls on normal usage - the missing piece was always a good runtime!

Pydantic classes allow for strong validation, serialization, deserialization, and type hinting quite nicely, reducing complexity for those familiar with python by providing expected usage methods and fields. A simple example on what I achieved so far:

from delusion.audio.cpp import AudioCPP, OmniVoice

audio = AudioCPP(
    model=OmniVoice(quant="q8_0").download()
)

# Uses NamedTemporaryFile internally
speak = audio.tts(text="お水はもう一杯もらえますか")
Path("output.wav").write_bytes(speak.wav)

Thanks, looking forward to make steady progress in the next weeks in the architecture and abstracted models! (still learning patterns)

Footnotes

  1. Don't feel like maintaining an official audio-cpp or audiocpp PyPI package, as I'm just a dev-user and don't intend to cover everything. Will look for server API calls and streaming later, cache is todo but easy. For the overall code quality target, see the existing chat sub-package or readme.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions