shift
done
-readchar=1
echo -n -e "\r" $items"- "
-while [ $readchar -ne 0 ]
-do
+while true ; do
echo -n -e "\r -"
- stty cbreak # or stty raw
- readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
+ stty cbreak # or stty raw. Stty uses file descriptor 0, not /dev/tty.
+ readchar=`dd bs=1 count=1 2>/dev/null`
stty -cbreak
- if [ $readchar == 'q' ] ; then
- readchar=0
- fi
- if [ $readchar -ne 0 ] ; then
+ if [ -n "$readchar" ] ; then
+ if [ $readchar == 'q' -o $readchar == 'Q' ] ; then
+ exit 0
+ fi
play -r 8000 -s -2 ${file[$readchar]} $dsp 2> /dev/null
fi
done
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
int main(int argc, char *argv[])
{
if (argc != 3) {
printf("usage: %s InputBitFile OutputRawSpeechFile\n", argv[0]);
- exit(0);
+ exit(1);
}
- fin = fopen(argv[1],"rb");
- if (fin == NULL) {
- printf("Error opening input bit file: %s\n", argv[1]);
- exit(0);
+ if ( (fin = fopen(argv[1],"rb")) == NULL ) {
+ fprintf(stderr, "Error opening input bit file: %s: %s.\n",
+ argv[1], strerror(errno));
+ exit(1);
}
- fout = fopen(argv[2],"wb");
- if (fout == NULL) {
- printf("Error opening output speech file: %s\n", argv[2]);
- exit(0);
+ if ( (fout = fopen(argv[2],"wb")) == NULL ) {
+ fprintf(stderr, "Error opening output speech file: %s: %s.\n",
+ argv[2], strerror(errno));
+ exit(1);
}
codec2 = codec2_create();
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
int main(int argc, char *argv[])
{
if (argc != 3) {
printf("usage: %s InputRawspeechFile OutputBitFile\n", argv[0]);
- exit(0);
+ exit(1);
}
- fin = fopen(argv[1],"rb");
- if (fin == NULL) {
- printf("Error opening input speech file: %s\n", argv[1]);
- exit(0);
+ if ( (fin = fopen(argv[1],"rb")) == NULL ) {
+ fprintf(stderr, "Error opening input bit file: %s: %s.\n",
+ argv[1], strerror(errno));
+ exit(1);
}
- fout = fopen(argv[2],"wb");
- if (fout == NULL) {
- printf("Error opening output bit file: %s\n", argv[2]);
- exit(0);
+ if ( (fout = fopen(argv[2],"wb")) == NULL ) {
+ fprintf(stderr, "Error opening output speech file: %s: %s.\n",
+ argv[2], strerror(errno));
+ exit(1);
}
codec2 = codec2_create();
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <math.h>
#include "defines.h"
nlp_states = nlp_create();
if (argc < 2) {
- printf("\nCodec2 - 2400 bit/s speech codec - Simulation Program\n");
- printf(" http://rowetel.com/codec2.html\n\n");
- printf("usage: %s InputFile [-o OutputFile]\n", argv[0]);
- printf(" [-o lpc Order]\n");
- printf(" [--lsp]\n");
- printf(" [--phase0]\n");
- printf(" [--postfilter]\n");
- printf(" [--hand_voicing]\n");
- printf(" [--dec]\n");
- printf(" [--dump DumpFilePrefix]\n");
- exit(0);
+ fprintf(stderr, "\nCodec2 - 2400 bit/s speech codec - Simulation Program\n"
+ "\thttp://rowetel.com/codec2.html\n\n"
+ "usage: %s InputFile [-o OutputFile]\n"
+ "\t[-o lpc Order]\n"
+ "\t[--lsp]\n"
+ "\t[--phase0]\n"
+ "\t[--postfilter]\n"
+ "\t[--hand_voicing]\n"
+ "\t[--dec]\n"
+ "\t[--dump DumpFilePrefix]\n", argv[0]);
+ exit(1);
}
/* Interpret command line arguments -------------------------------------*/
/* Input file */
if ((fin = fopen(argv[1],"rb")) == NULL) {
- printf("Error opening input speech file: %s\n",argv[1]);
+ fprintf(stderr, "Error opening input bit file: %s: %s.\n",
+ argv[1], strerror(errno));
exit(1);
}
if ((arg = switch_present("-o",argc,argv))) {
if ((fout = fopen(argv[arg+1],"wb")) == NULL) {
- printf("Error opening output speech file: %s\n",argv[arg+1]);
+ fprintf(stderr, "Error opening output speech file: %s: %s.\n",
+ argv[arg+1], strerror(errno));
exit(1);
}
strcpy(out_file,argv[arg+1]);
lpc_model = 1;
order = atoi(argv[arg+1]);
if ((order < 4) || (order > 20)) {
- printf("Error in lpc order: %d\n", order);
+ fprintf(stderr, "Error in lpc order: %d\n", order);
exit(1);
}
}