简体   繁体   English

FreeTTS语音无输出Raspberry PI蓝牙扬声器

[英]FreeTTS voice no output Raspberry PI bluetooth speaker

Have a simple program running on Raspberry PI. 在Raspberry PI上运行一个简单的程序。 When hooked up to monitor with speakers I can get the voice speaking through the HDMI speakers. 连接到带扬声器的显示器时,我可以通过HDMI扬声器获得声音。 However, I want the voice to output through bluetooth speakers. 但是,我希望声音通过蓝牙扬声器输出。 The connected bluetooth speakers play when I play some audio files, but when I run FreeTTS program the sound outputs either through HDMI audio or when headless and connected only to bluetooth speakers, there is no output at all. 当我播放一些音频文件时,连接的蓝牙扬声器会播放,但是当我运行FreeTTS程序时,声音将通过HDMI音频输出,或者无头且仅连接到蓝牙扬声器,则根本没有输出。 I'm thinking maybe it's trying to play through some default audio, since it plays through HDMI speakers even with bluetooth selected in audio menu... Here's the basic code I started with. 我在想也许它正在尝试播放某些默认音频,因为即使在音频菜单中选择了蓝牙,它也可以通过HDMI扬声器播放...这是我开始的基本代码。

Voice voice;
VoiceManager voiceManager = VoiceManager.getInstance();
voice = voiceManager.getVoice(voiceName);
voice.allocate();
voice.speak(text);

I've been trying additions, but nothing has worked so far. 我一直在尝试添加,但是到目前为止没有任何效果。 I was thinking I maybe needed to connect an AudioPlayer of some sort, but I couldn't get the default streaming one working. 我当时以为可能需要连接某种AudioPlayer,但无法使用默认的流媒体播放器。 I need the audio played immediately. 我需要立即播放音频。 Any thoughts? 有什么想法吗?

Turned out it wasn't really a programming issue, just configuration. 事实证明,这实际上不是编程问题,而只是配置。 I needed to have sound.properties setup for Java to use ALSA sound I guess. 我需要为Java安装sound.properties才能使用ALSA声音。 Once they were set, FreeTTS output to the correct audio as expected (in my case to a bluetooth speaker). 设置好后,FreeTTS将输出到期望的正确音频(在我的情况下,输出到蓝牙扬声器)。

javax.sound.sampled.Clip=com.sun.media.sound.DirectAudioDeviceProvider
javax.sound.sampled.Port=com.sun.media.sound.PortMixerProvider
javax.sound.sampled.SourceDataLine=com.sun.media.sound.DirectAudioDeviceProvider
javax.sound.sampled.TargetDataLine=com.sun.media.sound.DirectAudioDeviceProvider

Just put that in your sound.properties file (Somewhere in jdk/jvm folder: find / -name sound.properties ). 只需将其放在您的sound.properties文件中(在jdk / jvm文件夹中的某个位置: find / -name sound.properties )。 Should already be stubbed out in existing file, if not just throw it in there. 应该已经存根在现有文件中,如果不是仅将其扔在那里。

Since I was using bluetooth and needed to do some mixing, I eventually started using pulseaudio as well which led to other difficulties, but this still applied to getting Java sound working in that case as well. 由于我使用了蓝牙并且需要进行一些混合,因此我最终也开始使用pulseaudio,这带来了其他困难,但是在这种情况下,这仍然适用于使Java声音正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM