You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
here is my client (in the new wyoming-snd-external/test folder)
importwaveimportasynciofromtimeitimportdefault_timerastimerfromdatetimeimporttimedeltaimportargparseimportloggingfromwyoming.audioimportAudioChunk, AudioStart, AudioStop, AudioChunkConverterfromwyoming.clientimportAsyncTcpClientfromwyoming.infoimportDescribefromwyoming.eventimportasync_write_event, async_read_event_LOGGER=logging.getLogger("wav2speaker_client")
# expected Audio recording parametersRATE=16000# used in the read function to get a chunk of the audio fileCHUNK_SIZE=int(RATE/10) # 100ms# connect to the server snd port and return the connection object#@staticmethodasyncdefconnect(uri:str) ->AsyncTcpClient:
tcp=AsyncTcpClient.from_uri(uri)
awaittcp.connect()
returntcp# need to be async to use await on wyoming event functionsasyncdefmain() ->None:
"send audio file to playback/snd instance."debug:bool=False# define the arguments and --helpparser=argparse.ArgumentParser()
parser.add_argument("server", help="uri of the server to connect to")
parser.add_argument("wav_file", nargs="+", help="Path to WAV file(s) to transcribe")
parser.add_argument("--debug", action="store_true", default=False, help="Log DEBUG messages")
args=parser.parse_args()
# do the debugging logginglogging.basicConfig(level=logging.DEBUGifargs.debugelselogging.INFO)
ifargs.debug:
debug=args.debugifdebug==True:
_LOGGER.debug("server uri="+args.server)
# loop thru the wav files (may be one, space separated)forwave_fileinargs.wav_file:
ifdebug:
_LOGGER.debug("wave file="+wave_file)
snd_server_connection=Nonetry:
# connect to the snd serversnd_server_connection=awaitconnect(args.server)
except:
print("unable to connect to snd at "+args.server) //<===getthismessagereturn# use each wav file in turninput_wav_file=wave.open(wave_file, "r")
withinput_wav_file:
# send the describe eventawaitsnd_server_connection.write_event( Describe().event())
# read the info responseinfo_event=awaitsnd_server_connection.read_event()
# Input from wave file the audio characteristics, may need to convert to snd expected formatrate=input_wav_file.getframerate()
width=input_wav_file.getsampwidth()
channels=input_wav_file.getnchannels()
# send the transcribe event with languageawaitsnd_server_connection.write_event(AudioStart(rate,width,channels).event())
# no response from AudioStartifdebug:
_LOGGER.debug("file rate="+str(rate)+" width="+str(width)+" channels="+str(channels))
# get audio data from the file, audio_bytes=input_wav_file.readframes(CHUNK_SIZE)
# create a converter to insure the audio data is in the right format for the sndconverter=AudioChunkConverter(
rate=RATE, width=2, channels=1
)
# loop thru the audio buffer, whileaudio_bytes:
# convert to snd format as required (converter output format set before)chunk=converter.convert(
AudioChunk(rate, width, channels, audio_bytes)
)
# send this chunk to the snd awaitsnd_server_connection.write_event(chunk.event())
# get more data from the wav fileaudio_bytes=input_wav_file.readframes(CHUNK_SIZE)
# no more data, tell snd we are finished sending chunks# we will expect a full text output nowawaitsnd_server_connection.write_event(AudioStop().event())
# done with this snd awaitsnd_server_connection.disconnect();
if__name__=="__main__":
# because we want to use await in the main function we need # to launch as async task asyncio.run(main())
launched like this
test/wav2speaker.py
#!/usr/bin/env bashset-eopipefail# Directory of *this* scriptthis_dir="$( cd "$( dirname"$0" )" && pwd )"# Base directory of repobase_dir="$(realpath "${this_dir}/..")"# Path to virtual environment
: "${venv:=${base_dir}/.venv}"if [ -d"${venv}" ]; thensource"${venv}/bin/activate"ficdtestpython3"${base_dir}/test/wav2speaker.py" "$@
~/wyoming/wyoming-snd-external$ test/run_client_wav2speaker.sh
DEBUG:wav2speaker_client:server uri=tcp://localhost:10601
DEBUG:wav2speaker_client:wave file=test.wav
unable to connect to snd at tcp://localhost:10601
the test client for my asr works. asr local or in docker
I just did setup for the 1st time in the wyoming-snd-external folder
so MAY have newer code then asr
The text was updated successfully, but these errors were encountered:
SO... wyoming-snd-external doesn't implement Describe (which my client used) (maybe cause Describe didn't exist in 1.2?)
but now it connects, sends and the service plays the audio on the speaker.. so it is configured properly
earlier this year I created an asr, and built a test client, connect, transcribe, send audiochunks from 2 wav files,
check tanscript..
all good
trying to build my own service runner
testing each component as I go
snd,
mic
vad
wakeword
asr
tts
now I want to do the same test with the snd-external audio out to make sure connection to
local device works (and configured properly)
so I validated the audio output device (manually with aplay -D device_name wav_file) and started snd-external using those same parms
and replicated my wav client to use the snd events..
but it can't connect
the shell
connects as expected
netstat shows the socket listening
here is my client (in the new wyoming-snd-external/test folder)
launched like this
test/wav2speaker.py
and
test/run_client_wav2speaker.sh
#!/bin/bash test/wav2speaker.sh --debug tcp://localhost:10601 test.wav test1.wav
test
the test client for my asr works. asr local or in docker
I just did setup for the 1st time in the wyoming-snd-external folder
so MAY have newer code then asr
The text was updated successfully, but these errors were encountered: