Xamarin Android中的CrossTextToSpeech声音问题

时间:2018-01-25 10:37:00

标签: c# xamarin.forms cross-platform

我创建了一个.NET 2017解决方案来启动Text To Speech应用程序。我已经按照在线说明看似非常简单,我将TextToSpeech插件版本3.0.1添加到解决方案中,并将以下代码添加到便携式项目的MainPage中:

MainPage.xaml中

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:local="clr-namespace:XamarinTextToSpeech"
                 x:Class="XamarinTextToSpeech.MainPage">
        <ContentPage.Content>
            <StackLayout>
                <Entry x:Name="Enter" />
                <Button Text="Speak" Clicked="Button_Clicked" />
            </StackLayout>
        </ContentPage.Content>
    </ContentPage>

MainPage.xaml.cs中

using Plugin.TextToSpeech;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace XamarinTextToSpeech
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void Button_Clicked(object sender, EventArgs e)
        {
            var text = Enter.Text;
            CrossTextToSpeech.Current.Speak(text);

        }
    }
}

但是当我调试Android模拟器(VisualStudio_android-23_x86_phone)并在Entry文本框中输入内容时,没有声音。我已经完成了代码,输入的文本肯定会传入。

我错过了什么吗?任何帮助将不胜感激。

0 个答案:

没有答案