From adc24941a191ab266b39aed347c1544d0ce78527 Mon Sep 17 00:00:00 2001 From: dvs1 Date: Sun, 10 Nov 2024 14:27:16 +1000 Subject: Yet another failed attempt to get ALSA sub devices to work at boot time. --- aataaj.lua | 54 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 11 deletions(-) (limited to 'aataaj.lua') diff --git a/aataaj.lua b/aataaj.lua index a7e9d33..9776584 100755 --- a/aataaj.lua +++ b/aataaj.lua @@ -84,6 +84,30 @@ local options = update-rc.d aataaj.lua defaults mkdir -p /usr/local/share/doc/aataaj ln -s `pwd`/*.md /usr/local/share/doc/aataaj/ + pushd /usr/local/share/doc/aataaj + espeak-ng -w your.wav "Your " + espeak-ng -w devices.wav " audio devices are - " + espeak-ng -w device.wav "Device number " + espeak-ng -w sub.wav ", sub device " + espeak-ng -w zero.wav "zero" + espeak-ng -w one.wav "one" + espeak-ng -w two.wav "two" + espeak-ng -w three.wav "three" + espeak-ng -w four.wav "four" + espeak-ng -w five.wav "five" + espeak-ng -w six.wav "six" + espeak-ng -w seven.wav "seven" + espeak-ng -w eight.wav "eight" + espeak-ng -w nine.wav "nine" + espeak-ng -w ten.wav "ten" + espeak-ng -w eleven.wav "eleven" + espeak-ng -w twelve.wav "twelve" + espeak-ng -w thirteen.wav "thirteen" + espeak-ng -w fourteen.wav "fourteen" + espeak-ng -w fifteen.wav "fifteen" + espeak-ng -w sixteen.wav "sixteen" + espeak-ng -w best.wav "Please type the device number you heard best - " + popd ]]:log():show():Do() end os.exit(0) @@ -130,6 +154,7 @@ if _.runnable('catia') then GUI = 'catia' end local speaker = 'espeak' if _.runnable('espeak-ng') then speaker = 'espeak-ng' end +local numbers = {[0]='zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen'} local Cards = {} @@ -176,14 +201,21 @@ print('') io.flush() -local speak = function(card, subdevice, device, words, printIt, forkIt) - local file = os.tmpname() .. '.wav' - D('Creating temporary script file at ' .. file) --- local s = '#!/bin/bash\necho "' .. words .. '" | ALSA_CARD=' .. device .. ' ' .. speaker --- local s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -d hw:' .. device .. ',' .. subdevice - local s = '#!/bin/bash\n' .. speaker .. ' -d hw:' .. device .. ',' .. subdevice .. ' "' .. words .. '"' --- local s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -w ' .. file .. ' ; aplay --device=hw:' .. device .. ',' .. subdevice .. ' ' .. file --- local s = '#!/bin/bash\n' .. speaker .. ' -w ' .. file .. ' "' .. words .. '" ; aplay --device=hw:' .. device .. ',' .. subdevice .. ' ' .. file +local speak = function(card, subdevice, device, words, printIt, forkIt, ...) + local files = {...} + local s = '' + if 0 == #files then + local file = os.tmpname() .. '.wav' + D('Creating temporary script file at ' .. file) +-- s = '#!/bin/bash\necho "' .. words .. '" | ALSA_CARD=' .. device .. ' ' .. speaker +-- s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -d hw:' .. device .. ',' .. subdevice + s = '#!/bin/bash\n' .. speaker .. ' -d hw:' .. device .. ',' .. subdevice .. ' "' .. words .. '"' +-- s = '#!/bin/bash\necho "' .. words .. '" | ' .. speaker .. ' -w ' .. file .. ' ; aplay --device=hw:' .. device .. ',' .. subdevice .. ' ' .. file +-- s = '#!/bin/bash\n' .. speaker .. ' -w ' .. file .. ' "' .. words .. '" ; aplay --device=hw:' .. device .. ',' .. subdevice .. ' ' .. file + else + s = 'aplay --device=hw:' .. device .. ',' .. subdevice + for i, v in ipairs(files) do s = s .. ' ' .. v .. '.wav' end + end print(s) if printIt then print(words) end if forkIt then @@ -198,14 +230,14 @@ if 'start' == cmd then print('Your ' .. cnt .. ' audio devices are - ') for k,C in pairs(Cards) do for j,c in ipairs(C['playbackDevs']) do - speak(C.name, C['playbackDevs'][j], C.card - 1, 'Your ' .. cnt .. ' audio devices are - ', false, true) + speak(C.name, C['playbackDevs'][j], C.card - 1, 'Your ' .. cnt .. ' audio devices are - ', false, true, 'your', numbers[cnt], 'devices') end end -- TODO - should do a proper "wait for speakers to finish" here. Have fork(write a file), think that's what :wait(file) does. __'sleep 6':Do() for k,C in pairs(Cards) do for j,c in ipairs(C['playbackDevs']) do - speak(C.name, C['playbackDevs'][j], C.card - 1, 'Device number ' .. C.card - 1 .. ', sub device ' .. C['playbackDevs'][j] .. ' : ' .. C.name, true, false) + speak(C.name, C['playbackDevs'][j], C.card - 1, 'Device number ' .. C.card - 1 .. ', sub device ' .. C['playbackDevs'][j] .. ' : ' .. C.name, true, false, 'device', numbers[C.card - 1], 'sub', numbers[tonumber(C['playbackDevs'][j])]) end __'sleep 1':Do() end @@ -214,7 +246,7 @@ if 'start' == cmd then print('Please type the device number you heard best - ') for k,C in pairs(Cards) do for j,c in ipairs(C['playbackDevs']) do - speak(C.name, C['playbackDevs'][j], C.card - 1, 'Please type the device number you heard best - ', false, true) + speak(C.name, C['playbackDevs'][j], C.card - 1, 'Please type the device number you heard best - ', false, true, 'best') end end -- cgit v1.1