Swift.agi and SED error

I am attempting to use ‘swift.agi’ to do some TTS stuff with Cepstral. While it does work, there is a significant delay in playing the audio file, and I see this on the Asterisk CLI:

[quote=“Asterisk CLI”]/var/lib/asterisk/agi-bin/swift.agi: eval: line 10: unexpected EOF while looking for matching `"' /var/lib/asterisk/agi-bin/swift.agi: eval: line 11: syntax error: unexpected end of file /var/lib/asterisk/agi-bin/swift.agi: line 19: echo: write error: Broken pipe [/quote]

This is the swift.cgi file:

[quote=“swift.agi”][code]#!/bin/sh
text=echo $*
stdin="0"
while [ “$stdin” != “” ]
do
read stdin
if [ “$stdin” != “” ]
then
stdin2=echo $stdin | sed -e 's/: /=/' -e 's/"//g' -e 's/$/"/' -e 's/=/="/'
eval echo $stdin2
fi
done

calleridnum=echo $agi_callerid | cut -f2 -d\< | cut -f1 -d\>
calleridname=echo $agi_callerid | cut -f1 -d\<

/usr/local/bin/swift -o /tmp/$agi_uniqueid.wav -p audio/channels=1,audio/sampling-rate=8000 " $text "

echo “stream file /tmp/$agi_uniqueid #”

read stream
rm /tmp/$agi_uniqueid.wav

exit 0
[/code][/quote]

This is the line causing problems:

stdin2=echo $stdin | sed -e 's/: /=/' -e 's/"//g' -e 's/$/"/' -e 's/=/="/'

Ideas?

What is strange is that this error occurs on Ubuntu but not on OpenSuSE…