2026-01-18 16:26:16 +00:00
import { expect , tap } from '@git.zone/tstest/tapbundle' ;
2025-10-08 22:49:08 +00:00
import * as qenv from '@push.rocks/qenv' ;
2026-01-20 00:02:45 +00:00
import { SmartFs , SmartFsProviderNode } from '@push.rocks/smartfs' ;
2025-10-08 22:49:08 +00:00
const testQenv = new qenv . Qenv ( './' , './.nogit/' ) ;
2026-01-20 00:02:45 +00:00
const smartfs = new SmartFs ( new SmartFsProviderNode ( ) ) ;
2025-10-08 22:49:08 +00:00
import * as smartai from '../ts/index.js' ;
let testSmartai : smartai.SmartAi ;
tap . test ( 'ElevenLabs Audio: should create a smartai instance with ElevenLabs provider' , async ( ) = > {
testSmartai = new smartai . SmartAi ( {
elevenlabsToken : await testQenv . getEnvVarOnDemand ( 'ELEVENLABS_TOKEN' ) ,
elevenlabs : {
defaultVoiceId : '19STyYD15bswVz51nqLf' ,
} ,
} ) ;
await testSmartai . start ( ) ;
} ) ;
tap . test ( 'ElevenLabs Audio: should create audio response' , async ( ) = > {
const audioStream = await testSmartai . elevenlabsProvider . audio ( {
message : 'Welcome to SmartAI, the unified interface for the world\'s leading artificial intelligence providers. SmartAI brings together OpenAI, Anthropic, Perplexity, and ElevenLabs under a single elegant TypeScript API. Whether you need text generation, vision analysis, document processing, or premium text-to-speech capabilities, SmartAI provides a consistent and powerful interface for all your AI needs. Build intelligent applications at lightning speed without vendor lock-in.' ,
} ) ;
const chunks : Uint8Array [ ] = [ ] ;
for await ( const chunk of audioStream ) {
chunks . push ( chunk as Uint8Array ) ;
}
const audioBuffer = Buffer . concat ( chunks ) ;
2026-01-20 00:02:45 +00:00
await smartfs . file ( './.nogit/testoutput_elevenlabs.mp3' ) . write ( audioBuffer ) ;
2025-10-08 22:49:08 +00:00
console . log ( ` Audio Buffer length: ${ audioBuffer . length } ` ) ;
expect ( audioBuffer . length ) . toBeGreaterThan ( 0 ) ;
} ) ;
tap . test ( 'ElevenLabs Audio: should create audio with custom voice' , async ( ) = > {
const audioStream = await testSmartai . elevenlabsProvider . audio ( {
message : 'Testing with a different voice.' ,
voiceId : 'JBFqnCBsd6RMkjVDRZzb' ,
} ) ;
const chunks : Uint8Array [ ] = [ ] ;
for await ( const chunk of audioStream ) {
chunks . push ( chunk as Uint8Array ) ;
}
const audioBuffer = Buffer . concat ( chunks ) ;
2026-01-20 00:02:45 +00:00
await smartfs . file ( './.nogit/testoutput_elevenlabs_custom.mp3' ) . write ( audioBuffer ) ;
2025-10-08 22:49:08 +00:00
console . log ( ` Audio Buffer length (custom voice): ${ audioBuffer . length } ` ) ;
expect ( audioBuffer . length ) . toBeGreaterThan ( 0 ) ;
} ) ;
tap . test ( 'ElevenLabs Audio: should stop the smartai instance' , async ( ) = > {
await testSmartai . stop ( ) ;
} ) ;
export default tap . start ( ) ;