简体   繁体   English

Android可穿戴设备是否支持文字转语音?

[英]Do Android Wearables support text-to-speech?

I am trying to follow this tutorial for my Android wearables app: 我正在尝试为我的Android可穿戴应用程序遵循本教程:

https://www.sitepoint.com/using-android-text-to-speech-to-create-a-smart-assistant/ https://www.sitepoint.com/using-android-text-to-speech-to-create-a-smart-assistant/

Here is the code for my Activity file: 这是我的活动文件的代码:

import android.speech.tts.TextToSpeech;

public class ScoresActivity extends Activity {
    private TextToSpeech tts;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scores);

        // Text to speech setup
        tts = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                System.out.println("status: " + status);    // Always returns -1

                if (status == TextToSpeech.SUCCESS) {
                    int result = tts.setLanguage(Locale.US);
                    if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                        Log.e("TTS", "This Language is not supported");
                    }

                    speak("Hello");

                } else {
                    Log.e("TTS", "Initilization Failed!");
                }
            }
        });
    }

I always see this error message in the Logs: 我总是在日志中看到此错误消息: 在此处输入图片说明

Is it even possible to run the Android SDK's text-to-speech library on wearable devices? 甚至可以在可穿戴设备上运行Android SDK的文字转语音库吗? I tried running this code on a mobile Android app and everything worked fine. 我尝试在移动Android应用上运行此代码,并且一切正常。

Yes this is possible as they even have docs for this feauture in Adding Voice Capabilities : 是的,这是可能的,因为他们甚至在“ 添加语音功能”中都有有关此功能的文档:

Voice actions are an important part of the wearable experience. 语音动作是可穿戴体验的重要组成部分。 They let users carry out actions hands-free and quickly. 它们使用户可以免提快速执行操作。 Wear provides two types of voice actions: Wear提供两种语音操作:

System-provided These voice actions are task-based and are built into the Wear platform. 系统提供的这些语音操作基于任务,并内置于Wear平台中。 You filter for them in the activity that you want to start when the voice action is spoken. 您可以在说出语音操作时在要开始的活动中对其进行过滤。 Examples include "Take a note" or "Set an alarm". 示例包括“记笔记”或“设置闹钟”。

App-provided These voice actions are app-based, and you declare them just like a launcher icon. 由应用程序提供这些语音操作基于应用程序,您可以像启动器图标一样声明它们。 Users say "Start " to use these voice actions and an activity that you specify starts. 用户说“开始”以使用这些语音操作,并且您指定的活动开始。

You can also check this SO post for additional reference. 您也可以查看此SO帖子以获取其他参考。

Depends which device you have. 取决于您拥有的设备。 I think it needs to have android wear 2.0 and then possibly a speaker would make it more likely. 我认为它需要配备Android Wear 2.0,然后扬声器才可能使它更具可能性。 Im only saying that based on knowing my nixon mission does not have tts installed but the lg urbane 2 does. 我只是说,基于了解我的尼克松任务而没有安装tts,但是lg urbane 2却安装了tts。 Very annoying as tts could be used over bluetooth. 由于tts可以在蓝牙上使用,因此非常烦人。

Would be good to get a full listed of supported devices. 获取受支持设备的完整列表将是一件好事。

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

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