📄 demo.sh
字号:
#!/bin/bash -x#! /usr/local/bin/vm shell## This is a demo script for the new interface between shell scripts and# the voice library## $Id: demo.sh,v 1.3 2004/04/19 21:40:30 andyxem Exp $### Define the function to receive an answer from the voice library#function receive { read -r INPUT <&$VOICE_INPUT; echo "$INPUT"; }## Define the function to send a command to the voice library#function send { echo $1 >&$VOICE_OUTPUT;# kill -PIPE $VOICE_PID }## Let's see if the voice library is talking to us#echo File descriptors: $VOICE_INPUT, $VOICE_OUTPUTecho receiving hello shellANSWER=`receive`if [ "$ANSWER" != "HELLO SHELL" ]; then echo "$0: voice library not answering" >&2 exit 1fiecho sending hello voice program## Let's answer the message#send "HELLO VOICE PROGRAM"echo receive ready## Let's see if it worked#ANSWER=`receive`if [ "$ANSWER" != "READY" ]; then echo "$0: initialization failed" >&2 exit 1fi## Set the device##echo select dialup#if [ "$1" = "dialup" ]; then# send "DEVICE DIALUP_LINE"#else# send "DEVICE INTERNAL_SPEAKER"#fi## Let's see if it worked##echo receive ready #ANSWER=`receive`#if [ "$ANSWER" != "READY" ]; then# echo "$0: could not set output device" >&2# exit 1#fi#send "WAIT 10"#ANSWER=`receive`##if [ "$ANSWER" != "WAITING" ]; then# echo "$0: could not wait" >&2# exit 1#fi#ANSWER=`receive`#if [ "$ANSWER" != "READY" ]; then# echo "$0: could not wait" >&2# exit 1#fi## Let's send demo.rmd if it exists### Let's record a new demo.rmd if we are connected to the dialup# line##if [ "$1" = "dialup" ]; then # # Let's send a beep # send "BEEP 440 30" # # Let's see if it works # ANSWER=`receive` if [ "$ANSWER" != "BEEPING" ]; then echo "$0: could not send a beep" >&2 exit 1 fi ANSWER=`receive` if [ "$ANSWER" != "READY" ]; then echo "$0: could not send a beep" >&2 exit 1 fi # # Let's start the recording # send "RECORD demo.rmd" # # Let's see if it works # ANSWER=`receive` if [ "$ANSWER" != "RECORDING" ]; then echo "$0: could not start recording" >&2 exit 1 fi ANSWER=`receive` if [ "$ANSWER" != "READY" ]; then echo "$0: something went wrong on recording" >&2 exit 1 fi # # Let's send a final beep # send "BEEP 440 30" # # Let's see if it works # ANSWER=`receive` if [ "$ANSWER" != "BEEPING" ]; then echo "$0: could not send a beep" >&2 exit 1 fi ANSWER=`receive` if [ "$ANSWER" != "READY" ]; then echo "$0: could not send a beep" >&2 exit 1 fi#fiif [ -f demo.rmd ]; then echo play rmd send "PLAY demo.rmd" # # Let's see if it works # echo receive playing ANSWER=`receive` if [ "$ANSWER" != "PLAYING" ]; then echo "$0: could not start playing" >&2 exit 1 fi echo receive ready ANSWER=`receive` if [ "$ANSWER" != "READY" ]; then echo "$0: something went wrong on playing" >&2 exit 1 fifi ## Let's say goodbye#echo send goodbyesend "GOODBYE"## Let's see if the voice library got it#echo receive goodbye shellANSWER=`receive`if [ "$ANSWER" != "GOODBYE SHELL" ]; then echo "$0: could not say goodbye to the voice library" >&2 exit 1fiexit 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -