Help us understand the problem. What is going on with this article?

眺めて覚える C# Xamarin (6) 音声合成

早い話がAndroidにしゃべらすプログラムです。

なるべくちょいちょいとやるためには、Nugetでプラグインをインストールします。

Step1

image.png

Step2

image.png

Step3

image.png

Step4

image.png

Step5

image.png

nugetの追加

image.png

image.png
Xam.Plugins.TextToSpeechの導入

MainPage.xaml.cs
using Plugin.TextToSpeech; //プラグインの導入
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace Text2Speech
{

    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            //ボタンの定義
            var btn = new Button() { Text = "話す",FontSize=48 };
            btn.Clicked += Btn_Clicked;
            Content = btn;
        }
        /// <summary>
        /// ボタンクリック時の動作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Clicked(object sender, EventArgs e)
        {
            //喋らせる
            CrossTextToSpeech.Current.Speak("ソシアル ディスタンス。\n2メートル以上離れてください。\nソシアル ディスタンス。\n2メートル以上離れてください。\n");
        }
    }
}

実行結果

後からエレベータに駆け込んだお兄さんがおりた!

hiratarich
生涯プログラマ
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした