Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
arner committed Nov 1, 2020
0 parents commit 3623cb6
Show file tree
Hide file tree
Showing 7 changed files with 867 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
output
24 changes: 24 additions & 0 deletions 01-speak.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -e
#
# Run this script to generate wav files in GLaDOS' voice based on the lines in the input csv.
# Existing files are not overwritten. Requires curl.

inputfile=audio_default.csv
outputdir=output/speech

mkdir -p $outputdir

while IFS=, read -r name quotedtext; do
text="${quotedtext%\"}"
text="${text#\"}"

filename="$outputdir/$name"

echo "Processing: $text"
if [ ! -f "$filename" ]; then
curl -Ls --retry 30 --get --fail \
--data-urlencode "text=$text" \
-o "$filename" \
'https://glados.c-net.org/generate'
fi
done < $inputfile
9 changes: 9 additions & 0 deletions 02-process.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -e
#
# Normalize the volume of the spoken text.
# Requires ffmpeg-normalize (pip install ffmpeg-normalize) and ffmpeg (http://ffmpeg.org/download.html).

inputdir=output/speech
outputdir=output/result

ffmpeg-normalize $inputdir/*.wav --normalization-type peak --target-level 0 -of $outputdir -ext wav
12 changes: 12 additions & 0 deletions 03-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -e
#
# Package wav files in a directory to embed in a dustcloud image or upload to Valetudo for xiaomi gen1 and gen2.
# Requires ccrypt.

dir=output/result
sound_password="r0ckrobo#23456"

mkdir -p $dir

cd $dir
tar zc *.wav | ccrypt -e -K "$sound_password" > voicepack.pkg
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# GLaDOS voice pack builder

Give some personality to your Xiaomi vacuum by creating your own GLaDOS voice pack.

The script reads the text from the csv file in GLaDOS' voice and packages it for upload to your vacuum. It's been tested with a gen1 running [Valetudo](https://valetudo.cloud/) but should also work with other generations and with other ways of installing the voice pack.

Want to hear what it sounds like first? Check out [GLaDOS voice generator](https://glados.c-net.org/).

## Requirements

- curl to call the GLaDOS voice generator API.
- [ffmpeg](http://ffmpeg.org/) and ffmpeg-normalize (`pip install ffmpeg-normalize`) to normalize the volume of the voice files.
- ccrypt to package the wav files.

## Usage

- `git clone` this repo
- Change the lines in the csv file from the xiaomi default to something you want GLaDOS to say.
- Run `./01-speak.sh` to generate the speech.
- Run `./02-process.sh` to normalize the volume.
- Run `./03-package.sh` to package the wav files.
- Visit Valetudo in your browser (the IP of your vacuum) and go to Settings -> Sound and voice. Upload the generated .pkg file from the output/result directory and press 'Upload Voice Pack'.
- Done!

If you created a custom csv file, please be so kind to share it back so others can benefit from it.

## Tips

### Original samples

You can't beat the actual GLaDOS with her expression and cynicism, so why not replace some of the wav files with original samples from the game?

- Find the right samples, for instance on [here](http://www.portal2sounds.com/#w=glados).
- Download (via 'direct link') and give them the appropriate filenames (see the csv file).
- Convert mp3 to wav like this: `for i in *.mp3; do ffmpeg -i "$i" "${i%.*}.wav"; done`.
- Replace the respective files in the `output/result` directory and run the package script.

### Speak when bumping into something

Now we have this great voice installed, wouldn't it be great if GLaDOS would speak a bit more? How about a custom voice pack and configuration for this: [roborock-oucher](https://github.com/porech/roborock-oucher)?

### Further automations

If you are using [Home Assistant](https://www.home-assistant.io/), you can combine the control of your vacuum with other automations. How about a [soundtrack](https://www.youtube.com/watch?v=Y6ljFaKRTrI) or some light effects? The only limit is your willingness to release your inner geek - you know you want to ;).

## Credits

- Thanks to the folks over at [DustCloud](https://github.com/dgiese/dustcloud) for freeing our vacuums (and [transcribing the default voice](https://github.com/dgiese/dustcloud/blob/master/devices/xiaomi.vacuum/audio_generator/language/audio_en.csv)).
- [Valetudo](https://valetudo.cloud/) for the great ux.
- [b01t](https://dhampir.no/) for providing an API to his [GLaDOS voice generator](https://glados.c-net.org/).
96 changes: 96 additions & 0 deletions audio_default.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
back_dock_failed.wav,"Couldn't reach the charging dock, remove any obstacles, and clean the dock's transmission area."
back_dock_nearby.wav,"Cannot reach the dock, please remove any obstacles!"
bin_in.wav,"Dustbin installed."
bin_out.wav,"Dustbin removed."
binout_error10.wav,"Filter is clogged. Remove the dustbin, and clean the filter!"
bl_recovery_bootfailed.wav,"Failed to start. Restoring factory settings. This will take about 5 minutes."
bl_recovery_failed.wav,"Failed to restore factory settings. Try again."
bl_recovery_retry.wav,"Restoring factory settings. This will take about 5 minutes."
bl_recovery_start.wav,"Restoring factory settings. This will take about 5 minutes."
bl_recovery_updatefailed.wav,"Failed to update. Restoring factory settings. This will take about 5 minutes."
charging.wav,"Charging."
clean_bin.wav,"Empty the dustbin."
clean_finish.wav,"Finished cleaning. Going back to the dock."
di.wav,"Ding dong!"
ding.wav,"Ding!"
error_internal.wav,"An internal error occurred. Reboot the system."
error1.wav,"Error 1, Turn the laser unit, and check that it is not jammed, or blocked."
error2.wav,"Error 2, Clean and lightly tap the bumper."
error3.wav,"Error 3, Move the main unit to a new location, and restart."
error4.wav,"Error 4, Clean cliff sensors. Move the main unit away from any drops, then restart."
error5.wav,"Error 5, Remove and clean the main brush and brush bearing."
error6.wav,"Error 6, Remove and clean the side brush."
error7.wav,"Error 7, Check that wheels are not blocked, then move the main unit to a new location, and restart."
error8.wav,"Error 8, Remove any obstacles around the main unit."
error9.wav,"Error 9, Reinstall dustbin and filter."
error10.wav,"Error 10, Check the filter. If wet, use a dry one. If dry, clean it, and try again."
error11.wav,"Error 11, Strong magnetic field detected. Move the device away from barrier tape and restart."
error12.wav,"Error 12, Battery level too low, recharge before use."
error13.wav,"Error 13, Charging error. Clean charging contacts, and try again."
error14.wav,"Error 14, Battery error."
error15.wav,"Error 15, Clean wall sensor."
error16.wav,"Error 16, Place and start the main unit on a level floor."
error17.wav,"Error 17, Side brush module error. Reset the main unit."
error18.wav,"Error 18, Fan error. Reset the main unit."
error19.wav,"Error 19, There is no current on the charging base. Check connection to a power supply."
error21.wav,"Error 21, Height sensor has been pressed. Move the main unit, and restart."
error22.wav,"Error 22, Clean the recharge sensor on the main unit."
error23.wav,"Error 23, Clean the transmission area on the charging dock."
error24.wav,"Error 24, No-Go-Zone or barrier tape detected. Move the main unit away, and restart."
findme.wav,"Hi! I'm over here!"
finish.wav,"Cleaning completed."
goto.wav,"Going to the target."
goto_complete.wav,"Reached the target."
goto_failed.wav,"Could not reach the target."
home.wav,"Going back to the dock."
map_restore.wav,"Map has been restored, starting to charge."
no_power.wav,"Low battery, going back to the dock."
no_power_charging.wav,"Low battery. More charging needed."
no_spot_on_dock.wav,"Move the main unit to the target area, then start spot cleaning."
pause.wav,"Paused."
positioning.wav,"Positioning, please wait."
power_off.wav,"Turning off."
power_off_rejected.wav,"Take the main unit off the charging dock to turn off."
power_resume_clean.wav,"Battery charged, resuming cleaning."
relocate_failed.wav,"Route planning failed, could not reach the target."
remote.wav,"Starting remote control."
remote_complete.wav,"Remote control stopped."
restart_backtodock_ignore_forbidden_zone.wav,"Position failed. The virtual wall of the No-Go-Zone is invalid. Continue recharging."
restart_clean.wav,"Positioning failure, starting a new clean."
restart_clean_fromdock.wav,"Positioning failure, starting a new clean to rebuild the map."
restart_clean_ignore_forbidden_zone.wav,"Positioning failed. The virtual wall of the No-Go-Zone is invalid. Start a new cleaning session."
restart_clean_nodock.wav,"Positioning failure, invalid map. Starting a new clean."
restart_spot_ignore_forbidden_zone.wav,"Position failed. The virtual wall of the No-Go-Zone is invalid. Continuing spot cleaning."
resume_backtodock.wav,"Positioning failure, invalid map. Continue returning to the dock."
resume_clean.wav,"Resuming cleaning."
resume_home.wav,"Continue returning to the dock."
resume_room.wav,"Resuming room cleaning."
resume_spot.wav,"Positioning failure, invalid map. Continuing spot cleaning."
resume_zone.wav,"Resuming zoned cleaning."
return_no.wav,"Couldn't return to the starting point."
return_yes.wav,"Couldn't find the dock. Bring main unit closer to the dock, and retry."
room.wav,"Starting room cleaning."
room_complete.wav,"Room cleaning complete, going back to the dock."
room_failed.wav,"Room cleaning incomplete, could not reach a specified room, going back to the dock."
room_partialdone.wav,"Room cleaning complete, going back to the dock. Some areas could not be reached."
saving_map.wav,"Saving map, please wait."
spot.wav,"Starting spot cleaning."
start.wav,"Starting to clean."
stop.wav,"Finished cleaning."
stop_clean.wav,"Stop cleaning."
stop_goto.wav,"Stopping travel to target."
stop_room.wav,"Stop targeted room cleaning."
stop_scheduled_clean.wav,"Positioning failed. Scheduled cleaning cancelled."
stop_spot.wav,"Stopped spot cleaning."
stop_zone.wav,"Stopped targeted area cleaning."
sysupd_complete.wav,"Update complete."
sysupd_failed.wav,"Couldn't update firmware. Returning to previous version."
sysupd_notready.wav,"Recharge to at least twenty percent before updating."
sysupd_start.wav,"Updating firmware. This may take 5 to 10 minutes."
sysupd_wip.wav,"Updating. Please wait."
timed_clean.wav,"Starting scheduled cleaning."
wifi_reset.wav,"Resetting Wi-Fi."
zone.wav,"Starting zoned cleanup."
zone_complete.wav,"Zoned cleaning completed. Going back to the dock."
zone_failed.wav,"Zoned cleaning incomplete. Could not reach a specified zone. Going back to the dock."
zone_partialdone.wav,"Zone cleaning completed. Going back to the dock. Some zones could not be reached."

0 comments on commit 3623cb6

Please sign in to comment.