← Back to context

Comment by mistersquid

2 days ago

> Chatterbox is fantastic.

> I created an API wrapper that also makes installation easier (Dockerized as well) https://github.com/travisvn/chatterbox-tts-ap

Gave your wrapper a try and, wow, I'm blown away by both Chatterbox TTS and your API wrapper.

Excuse the rudimentary level of what follows.

Was looking for a quick and dirty CLI incantation to specify a local text file instead of the inline `input` object, but couldn't figure it.

Pointers much appreciated.

This API wrapper was initially made to support a particular use case where someone's running, say, Open WebUI or AnythingLLM or some other local LLM frontend.

A lot of these frontends have an option for using OpenAI's TTS API, and some of them allow you to specify the URL for that endpoint, allowing for "drop-in replacements" like this project.

So the speech generation endpoint in the API is designed to fill that niche. However, its usage is pretty basic and there are curl statements in the README for testing your setup.

Anyway, to get to your actual question, let me see if I can whip something up. I'll edit this comment with the command if I can swing it.

In the meantime, can I assume your local text files are actual `.txt` files?

  • This is way more of a response than I could have even hoped for. Thank you so much.

    To answer your question, yes, my local text files are .txt files.

    • Ok, here's a command that works.

      I'm new to actually commenting on HN as opposed to just lurking, so I hope this formatting works..

        cat your_file.txt | python3 -c 'import sys, json; print(json.dumps({"input": sys.stdin.read()}))' | curl -X POST http://localhost:5123/v1/audio/speech \
          -H "Content-Type: application/json" \
          -d @- \
          --output speech.wav
      
      

      Just replace the `your_file.txt` with.. well, you get it.

      This'll hopefully handle any potential issues you'd have with quotes or other symbols breaking the JSON input.

      Let me know how it goes!

      Oh and you might want to change `python3` to `python` depending on your setup.

      4 replies →