Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds --server and --volume option #378

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

flatsiedatsie
Copy link

This runs the core of the project in a loop until the process receives a termination signal.

After creating this issue I thought I'd see if I could add "server" functionality myself. It's probably not optimal, since I'm not a C++ coder. The bool running = true part might not be needed.

This runs the core of the project in a loop until the process receives a termination signal.
@flatsiedatsie
Copy link
Author

The second commit to this pull request adds a -v or --volume option, which lets users set the desired output volume of the audio.

This also works with JSON input, to change the volume while in server mode. E.g.

echo '{"text":"Bla bla bla","volume_level":"0.1"}' | ./piper --model /home/pi/tts/en_US-lessac-medium.onnx --json-input --server --output-raw -volume 0.8 --sentence_silence 0.1 | aplay -D plughw:0,0 -r22050 -fS16_LE -t raw -

@flatsiedatsie flatsiedatsie changed the title Add --server option Adds --server and --volume option Feb 15, 2024
@akhil3417
Copy link

akhil3417 commented Feb 26, 2024

how would on go about using this server(i.e make requests)? how's this different from https://github.com/rhasspy/piper/blob/master/src/python_run/README_http.md

@flatsiedatsie
Copy link
Author

flatsiedatsie commented Feb 28, 2024

It's not really a server, it's a long-running cli process.

  • Useful when using cli is prefered over server route (e.g. avoid port use / manage all sub-processes similarly)
  • Output can be piped directly to aplay as it is generated

Making a request works as follows:

if self.llm_tts_process.poll() == None:
    if self.DEBUG:
        print("llm_speak: LLM TTS Process is running")
    json_voice_message = '{ "text": "' + str(voice_message).replace('"', '\\"') + '","volume_level":"' + str( int(self.persistent_data['speaker_volume'])/100) + '"}\n'
    if self.DEBUG: 
        print("piping json into Piper: " + str(json_voice_message))
    self.llm_tts_process.stdin.write(json_voice_message)
    self.llm_tts_process.stdin.flush()

Looking back, --server is probably the wrong name for this feature if a real server already exists.

@akhil3417
Copy link

akhil3417 commented Feb 28, 2024

thanks, since the piper-tts python package doesn't sound as good (since the binary uses patched espeak-ng), this is alternative for now. can you share the binary ?

@flatsiedatsie
Copy link
Author

Sure, the binary can be found here: https://github.com/createcandle/voco/tree/master/llm/tts

Implementation example can be found here:
https://github.com/createcandle/voco/blob/master/pkg/voco_adapter.py

@akhil3417
Copy link

akhil3417 commented Feb 28, 2024

linked binary was aarch64, forgot to mention but m running x86_64 arch.

exec: Failed to execute process: './piper' the file could not be run by the operating system.

@flatsiedatsie
Copy link
Author

Then you'll have to compile it yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants