I am working here on a MacBook with El Capitan on it. OS X has an integrated text to speech program, that you can use via the command say
.
The problem I have with this command is that my MacBook is kind of old and runs out of RAM quickly. So, I can use this command, but the first two sentences will sound really off, while the next sentences sound perfect.
I use the say
command at the end of my alarm and egg-timer script, giving out a message. Right now I use bsay
which is a little script written by me:
#!/bin/bash
path="/Users/joe/.joe_script/resources/bsay/"
name=".$(date "+%s").ogg"
say -o ${path}$name "$*"
afplay ${path}$name
rm $path$name
This works quite fine so far. Yet, I think it should even be better. I wanted to hold it in RAM and play it in RAM instead of writting it down on my drive. I have just no clue how to archieve that. At first, I imagined a single string would do it. I tried to simply do it by using the following line:
audio=$(say "Whatever I want to say")
It spoke it aloud instead. Than I thought, I just add prove of concept and tried this:
say -o output.ogg "Whatever I want to say"
audio="$(cat output.ogg)"
afplay $audio
That just gave me an explanation how afplay works... okay, bummer.. afplay doesn't support variables. But as a prove of concept, I tried this:
say -o output.ogg "Whatever I want to say"
audio="$(cat output.ogg)"
echo $audio >> output2.ogg
afplay output2.ogg
Which in turn did only give me back an error message:
Error: AudioFileOpen failed ('typ?')
So, I assume I am far off with my attempts. Can someone give me any hints or directions in which I could archieve something like that?