Using spd-say in a bash script function
I'm sure this is fairly elementary, but I can't figure it out.
My script:
#!/bin/bash
sez ()
{
echo $1
spd-say "$1"
}
sez "does this work"
sez "this does work"
What I'm trying to make happen is use spd-say in a function to make the computer talk to me.
The echo portion of my function works. It outputs both lines of text that I feed to it in the expected order. However, the spd-say part doesn't. It only ever says the last line. I'm assuming it's because the second command is "overwriting" the output of the first because it's trying to run them in parallel to the same output. I've tried adding ;wait, &&, and various other things to the end of the sez command, on the next line after, within the function on the spd-say command, etc, but everything I'm trying isn't helping.
What am I doing wrong?
bash shell-script audio function text-to-speech
add a comment |
I'm sure this is fairly elementary, but I can't figure it out.
My script:
#!/bin/bash
sez ()
{
echo $1
spd-say "$1"
}
sez "does this work"
sez "this does work"
What I'm trying to make happen is use spd-say in a function to make the computer talk to me.
The echo portion of my function works. It outputs both lines of text that I feed to it in the expected order. However, the spd-say part doesn't. It only ever says the last line. I'm assuming it's because the second command is "overwriting" the output of the first because it's trying to run them in parallel to the same output. I've tried adding ;wait, &&, and various other things to the end of the sez command, on the next line after, within the function on the spd-say command, etc, but everything I'm trying isn't helping.
What am I doing wrong?
bash shell-script audio function text-to-speech
add a comment |
I'm sure this is fairly elementary, but I can't figure it out.
My script:
#!/bin/bash
sez ()
{
echo $1
spd-say "$1"
}
sez "does this work"
sez "this does work"
What I'm trying to make happen is use spd-say in a function to make the computer talk to me.
The echo portion of my function works. It outputs both lines of text that I feed to it in the expected order. However, the spd-say part doesn't. It only ever says the last line. I'm assuming it's because the second command is "overwriting" the output of the first because it's trying to run them in parallel to the same output. I've tried adding ;wait, &&, and various other things to the end of the sez command, on the next line after, within the function on the spd-say command, etc, but everything I'm trying isn't helping.
What am I doing wrong?
bash shell-script audio function text-to-speech
I'm sure this is fairly elementary, but I can't figure it out.
My script:
#!/bin/bash
sez ()
{
echo $1
spd-say "$1"
}
sez "does this work"
sez "this does work"
What I'm trying to make happen is use spd-say in a function to make the computer talk to me.
The echo portion of my function works. It outputs both lines of text that I feed to it in the expected order. However, the spd-say part doesn't. It only ever says the last line. I'm assuming it's because the second command is "overwriting" the output of the first because it's trying to run them in parallel to the same output. I've tried adding ;wait, &&, and various other things to the end of the sez command, on the next line after, within the function on the spd-say command, etc, but everything I'm trying isn't helping.
What am I doing wrong?
bash shell-script audio function text-to-speech
bash shell-script audio function text-to-speech
edited Aug 20 '18 at 22:35
Rui F Ribeiro
41.8k1483142
41.8k1483142
asked Oct 9 '16 at 15:06
lightwinglightwing
498
498
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I had a similar problem and I found a workaround. Instead of using spd-say I used espeak directly.
add a comment |
spd-say requires a suitable shell environment. cron doesn't execute tasks in your regular shell environment.
You can try changing your script such as in this example:
#!/bin/bash
source $HOME/.profile
sez ()
{
echo $1
spd-say "$1"
}
sez "does this work"
sez "this does work"
See also this question for more information: http://unix.stackexchange.com/questions/67940/cron-ignores-variables-defined-in-bashrc-and-bash-profile
New contributor
user344053 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f315289%2fusing-spd-say-in-a-bash-script-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I had a similar problem and I found a workaround. Instead of using spd-say I used espeak directly.
add a comment |
I had a similar problem and I found a workaround. Instead of using spd-say I used espeak directly.
add a comment |
I had a similar problem and I found a workaround. Instead of using spd-say I used espeak directly.
I had a similar problem and I found a workaround. Instead of using spd-say I used espeak directly.
edited Dec 4 '16 at 14:05
Jeff Schaller♦
44k1161142
44k1161142
answered Dec 4 '16 at 10:00
alagrisalagris
465
465
add a comment |
add a comment |
spd-say requires a suitable shell environment. cron doesn't execute tasks in your regular shell environment.
You can try changing your script such as in this example:
#!/bin/bash
source $HOME/.profile
sez ()
{
echo $1
spd-say "$1"
}
sez "does this work"
sez "this does work"
See also this question for more information: http://unix.stackexchange.com/questions/67940/cron-ignores-variables-defined-in-bashrc-and-bash-profile
New contributor
user344053 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
spd-say requires a suitable shell environment. cron doesn't execute tasks in your regular shell environment.
You can try changing your script such as in this example:
#!/bin/bash
source $HOME/.profile
sez ()
{
echo $1
spd-say "$1"
}
sez "does this work"
sez "this does work"
See also this question for more information: http://unix.stackexchange.com/questions/67940/cron-ignores-variables-defined-in-bashrc-and-bash-profile
New contributor
user344053 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
spd-say requires a suitable shell environment. cron doesn't execute tasks in your regular shell environment.
You can try changing your script such as in this example:
#!/bin/bash
source $HOME/.profile
sez ()
{
echo $1
spd-say "$1"
}
sez "does this work"
sez "this does work"
See also this question for more information: http://unix.stackexchange.com/questions/67940/cron-ignores-variables-defined-in-bashrc-and-bash-profile
New contributor
user344053 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
spd-say requires a suitable shell environment. cron doesn't execute tasks in your regular shell environment.
You can try changing your script such as in this example:
#!/bin/bash
source $HOME/.profile
sez ()
{
echo $1
spd-say "$1"
}
sez "does this work"
sez "this does work"
See also this question for more information: http://unix.stackexchange.com/questions/67940/cron-ignores-variables-defined-in-bashrc-and-bash-profile
New contributor
user344053 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user344053 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 1 min ago
user344053user344053
1
1
New contributor
user344053 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user344053 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
user344053 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f315289%2fusing-spd-say-in-a-bash-script-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown