Skip to content

Conversation

@justjam2013
Copy link

@justjam2013 justjam2013 commented Jul 17, 2025

Add a new endpoint to save the generated audio to a .wav file.

Use case: I am currently using rhasspy/piper running in a Docker container alongside Homebridge (Homekit accessory bridge). A HomeKit automation runs every morning and requests generated audio from Piper. containing the current time, weather forecast, and top news headlines. Due to constraints in HomeKit, the generated audio is saved to file in a shared location. A Homebridge plugin then reads the generated speech file and AirPlays it to a HomePod.

Adding the "GET" method is not a requirement. It simply makes is easier to generate a short test request from a browser, rather than Postman. However due to the length constraint in GET requests, I do not use this in my "production" environment.

@justjam2013
Copy link
Author

This PR provides a code change for issue Add ability to save generated audio to file instead of downloading

@synesthesiam synesthesiam self-assigned this Jul 17, 2025
@synesthesiam
Copy link
Contributor

I appreciate the PR, but I don't really like the idea of the web server being able to write audio to the server's file system. I understand this would (in principle) be restricted to the provided media directory, but what you have here could easily be bypassed by providing something with "../" in the filename.

@justjam2013
Copy link
Author

justjam2013 commented Jul 28, 2025

what you have here could easily be bypassed by providing something with "../" in the filename.

If that is your concern, then you could have commented without closing the PR. That could easily be handled by sanitizing the URL and disallowing "../". The media folder is passed to the server as a startup value, so restricting the filename to [A-Za-z_] and single dot (as in abc.xyz or abc.def.xyz) would fix it. I didn't consider the double dot, just potentially subfolders.

Also, as the media folder is passed to the server as a startup value, the folder doesn't have to be in the server folder. It could be a shared folder on the host or a remote or mounted folder.

@synesthesiam synesthesiam reopened this Jul 28, 2025
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.

2 participants