KoljaB / RealtimeTTS

Converts text to speech in realtime
1.39k stars 119 forks source link

.play(muted=True) in VPS but error ALSA lib confmisc.c:855:(parse_card) cannot find card '0 #53

Open user080975 opened 3 months ago

user080975 commented 3 months ago

I'm trying to run a simple TextToAudioStream in an Ubuntu Lightsail container on AWS like this to stream to browser js:

stream = client.chat.completions.create( model="gpt-4-turbo-preview", messages=[{"role": "user", "content": text}], stream=True ) tts_stream = TextToAudioStream( AzureEngine( speech_key='', service_region='westeurope', voice='zh-CN-XiaochenMultilingualNeural', rate='5' ), log_characters=True ) tts_stream.feed(stream).play(on_audio_chunk=handle_audio_chunk, muted=True)

This works in my local environment with muted=True but I'm getting this error even though I don't require audio playback and set muted=True

Is there a way around this or somehow to get this working in a VPS environment?

ALSA lib confmisc.c:855:(parse_card) cannot find card '0' ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings ... ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM sysdefault ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear

KoljaB commented 3 months ago

Seriously, are you all in a secret competition to see who can find the most obscure setup? You might need to set up a dummy soundcard for ALSA but how to do this in linux exactly is beyond my scope actually.

user080975 commented 3 months ago

😂

user080975 commented 3 months ago

Actually I think most dev's would be looking to set this up in a remote VPS / headless mode and then calling it remotely instead of direct local playback.

KoljaB commented 3 months ago

Yeah, just kidding. It's a very reasonable environment, not one of those "I have this super special Linux distro with a dinosaur Python environment" situations. My horizon is just really narrow; anything that's not Windows immediately seems somehow exotic to me.

PylotLight commented 3 months ago

Still having similar trouble, go audio to work in wsl via demo paplay /usr/share/sounds/alsa/Front_Center.wav But loading any engine still results in ALSA lib confmisc.c:855:(parse_card) cannot find card '0' ALSA lib conf.c:5180:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory...

TerryWong1024 commented 3 months ago

@user080975 I got the same problem, did u resolve it? could you please share the Wechat No, we can contact with u in Wechat

user080975 commented 3 months ago

@user080975 I got the same problem, did u resolve it? could you please share the Wechat No, we can contact with u in Wechat

No I didn't solve the problem but since I mostly use Node JS, I wrote a custom JS solution based on Kolja's code logic.

TerryWong1024 commented 3 months ago

@user080975 I got the same problem, did u resolve it? could you please share the Wechat No, we can contact with u in Wechat

No I didn't solve the problem but since I mostly use Node JS, I wrote a custom JS solution based on Kolja's code logic.

Thanks for your reply, you cross this issue by coding a Webservice to call the Kolja's code logic? please specify, thanks in advanced.

TerryWong1024 commented 3 months ago

@user080975 I got the same problem, did u resolve it? could you please share the Wechat No, we can contact with u in Wechat

No I didn't solve the problem but since I mostly use Node JS, I wrote a custom JS solution based on Kolja's code logic.

Thanks for your reply, you cross this issue by coding a Webservice to call the Kolja's code logic? please specify, thanks in advanced.

@user080975 Sorry to interrupt,Could you please specify the solution, i have been stuck with this question for long time。

arreumb commented 1 month ago

Same problem here, no way to use TextToAudioStream() in a lightning.ai virtual server: ALSA lib confmisc.c:767:(parse_card) cannot find card '0' And I can't create a virtual sound device because command modprobe is not available.

KoljaB commented 1 month ago

Added a global muted parameter to TextToStream that prevents opening an output stream with pyAudio. With this parameter set to True it should be possible to use on_audio_chunk callback and output_wavfile parameters without the need for any sound device.

arreumb commented 1 month ago

Works for me. Thanks.