文字轉語音小軟體

2022-09-19 13:12:15 字數 1242 閱讀 3110

把文字轉成語音這個功能是很常用的,如果不追求語音個性,只需要短短幾行**就可以實現。

**,專案中引用

using system.speech.synthesis;
四行**實現說話:

using (speechsynthesizer voice = new

speechsynthesizer())

封裝一下:

using

system;

using

system.collections.generic;

using

system.linq;

using

system.speech.synthesis;

using

system.text;

using

system.threading.tasks;

namespace

speakhello

//////

播報語音

/// ///

內容 ///

語速[-10,10]

///音量[0,100]

public

static

void speak(string msg, int rate, int

volume)}}

}

拓展一下:

除了預設的安娜語音外,還可以安裝其他聲音:microsoft mary,microsoft mike和sample tts voice

speaker.selectvoice("

microsoft mike

");

system.speech和microsoft.speech是不同的,並且為了避免混淆,應該只選擇其中之一。

對於system.speech

轉到設定/區域和語言/新增語言

對於microsoft.speech

新增對     專案中的microsoft.speech dll

用於microsoft支援的語言的語音識別和文字到語音引擎 

有關更多資訊:

microsoft語音程式設計指南

speechsynthesizer.selectvoice方法

system.speech.synthesis命名空間

文字轉語音

你要轉換的文字 引數說明 lan zh 語言是中文,如果改為lan en,則語言是英文。ie utf 8 文字格式。spd 2 語速,可以是1 9的數字,數字越大,語速越快。text 這個就是你要轉換的文字。var arr 張三 李四 王五 趙六 劉德華 張學友 趙本山 var i i math.f...

Android文字轉語音

雖然視覺上的反饋通常是給使用者提供資訊最快的方式,但這要求使用者把注意力裝置上。當使用者不能檢視裝置時,則需要一些其他通訊的方法。android提供了強大的文字轉語音text to speech,tts api。使開發者能夠在應用中新增語音通知和其他語音反饋功能,而不要求使用者看著螢幕。下面的 展示...

python 文字轉語音

import pyttsx3 初始化,必須要有 engine pyttsx3.init engine.say hello engine.say 我會說中文了,開森,開森 注意,沒有本句話是沒有聲音的 engine.runandwait engine.say 我能說第二句話了 engine.runan...