Unity文字转语音

仅限于Windows系统PC端,如果是webgl需要接入讯飞语音SDK。

插件链接:https://download.csdn.net/download/ThreePointsHeat/12914777

调用:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using SpeechLib;
using UnityEngine.UI;

public class Test : MonoBehaviour
{
    public InputField input;
    public Button button;
    SpVoice voice;
    void Start()
    {
        voice = new SpVoice();
        button.onClick.AddListener(Button_Event);
    }

    private void Button_Event() {
        voice.Speak(input.text);
    }    
}

打包的时候注意将Api Compatibility Level改为 .NET 4.x

最后运行打包的exe即可。 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Unity文字转语音是指在Unity开发环境下使用插件或代码实现将文字转换为语音的功能。在Unity中,有一些插件可以实现这一功能,比如RtVioce插件。通过使用这些插件,开发者可以在Unity中将文字转换为语音,并可以根据需要选择不同的音色和扬声器进行转换和播放。具体的实现方式可以通过调用TTS功能来实现,比如使用TextToSpeech.Instance.StartSpeaking的方法来将指定的文字转换为语音。转换完成后,生成的音频可以存储到文件中,并可以通过使用audio source组件进行播放。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [unity文字转语音插件.rar](https://download.csdn.net/download/qq_43505432/16751694)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Unity3D HoloLens2 中文文字转语音即语音合成(语音提示)功能](https://blog.csdn.net/qq_33789001/article/details/112345062)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值