// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Spoken digit reader // Not compiled or tested in-world // Setup: Add short sounds named digit_0 through digit_9. Owner-touch asks for up to eight digits. Touch during speech cancels. // Stop / restore: Owner-touch the script prim to stop an active session before removing or resetting it. Loop state can survive script removal; use Stop sound in this prim if necessary. // Notes: Use licensed sounds in this prim. Audio is nearby, not private. Timer timing and asset loading are approximate; no sample synchronization is promised. Not text-to-speech: all ten spoken digits are supplied inventory assets. One digit per second. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Not compiled or tested in-world. integer channel; integer handle; string digits; integer index; integer playing; close() { if(handle)llListenRemove(handle); handle=0; llSetTimerEvent(0.0); } default { touch_start(integer n) { if(llDetectedKey(0)!=llGetOwner())return; if(playing) { playing=FALSE; digits=""; llStopSound(); close(); return; } close(); channel=-1000-(integer)llFrand(1000000.0); handle=llListen(channel,"",llGetOwner(),""); llTextBox(llGetOwner(),"Enter 1-8 digits to hear.",channel); llSetTimerEvent(30.0); } listen(integer ch,string name,key id,string s) { if(!handle||ch!=channel||id!=llGetOwner())return; close(); s=llStringTrim(s,STRING_TRIM); if(llStringLength(s)<1||llStringLength(s)>8)return; integer i; for(i=0;i=llStringLength(digits)) { playing=FALSE; llSetTimerEvent(0.0); return; } string sound="digit_"+llGetSubString(digits,index,index); ++index; if(llGetInventoryType(sound)==INVENTORY_SOUND)llPlaySound(sound,0.25); } }