csharp: 百度语音合成
public string API_id = "3333"; //你的ID
public string API_record = null;
public string API_record_format = null;
public string API_record_HZ = null;
public string API_key = "geovindu"; //你的KEY
public string API_secret_key = "geovindu"; //你的SECRRET_KEY
public string API_language = null;
public string API_access_token = null;
public string strJSON = "";
private const string tex = "远去的山河沉寂,恋过的风景如昔." +
"苍何斩落了情迷,生死轻付了别离." +
"捣一脉相思成泥,沐四海悲风无迹." +
"往生海烟波又起,妙华镜风雪共历."; /// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{ }
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
API_access_token = getStrAccess(API_key, API_secret_key);
Guid cid = new Guid();
Response.Redirect("http://tsn.baidu.com/text2audio?tex=" + tex + "&lan=zh&cuid=" + cid.ToString() + "&ctp=1&tok=" + API_access_token); }
/// <summary>
///
/// </summary>
/// <param name="para_API_key">你的KEY</param>
/// <param name="para_API_secret_key">你的SECRRET_KEY</param>
/// <returns></returns>
public string getStrAccess(string para_API_key, string para_API_secret_key)
{ //方法参数说明:
//para_API_key:API_key(你的KEY)
//para_API_secret_key(你的SECRRET_KEY)
//方法返回值说明:
//百度认证口令码,access_token
string access_html = null;
string access_token = null;
string getAccessUrl = "https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials" + "&client_id=" + para_API_key + "&client_secret=" + para_API_secret_key;
try
{
HttpWebRequest getAccessRequest = WebRequest.Create(getAccessUrl) as HttpWebRequest;
//getAccessRequest.Proxy = null;
getAccessRequest.ContentType = "multipart/form-data";
getAccessRequest.Accept = "*/*";
getAccessRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)";
getAccessRequest.Timeout = 30000;//30秒连接不成功就中断
getAccessRequest.Method = "post";
HttpWebResponse response = getAccessRequest.GetResponse() as HttpWebResponse;
using (StreamReader strHttpComback = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
access_html = strHttpComback.ReadToEnd();
}
}
catch (WebException ex)
{
Response.Write(ex.ToString());
} JObject jo = JObject.Parse(access_html);
access_token = jo["access_token"].ToString();//得到返回的toke
return access_token;
}
程序还未完善。
注:有效符号多或特殊符号的,无法读文章,百度有字数限制。可能要特珠服务需要购买。
网址DEMO:http://www.dusystem.com/news/show-184.html
API请求方式基本说明
http://yuyin.baidu.com/docs/tts/136
语音合成接口支持 POST 和 GET两种方式
正式地址:http://tsn.baidu.com/text2audio
csharp: 百度语音合成的更多相关文章
- C# 百度语音合成
语音合成及TTS,我们尝试使用百度的语音合成技术 不过我发现 有一种缺点在于没有离线包让我有些很不舒服,可能是在线版的 原因微软语音识别技术在Windows 2000是默认集成在系统组件中 或许我们不 ...
- 百度语音合成AI
注意:不要使用Dw编辑PHP代码,会因为编码问题出错!!<?php require_once 'AipSpeech.php'; // 你的 APPID AK SK const APP_ID = ...
- flask 第六章 人工智能 百度语音合成 识别 NLP自然语言处理+simnet短文本相似度 图灵机器人
百度智能云文档链接 : https://cloud.baidu.com/doc/SPEECH/index.html 1.百度语音合成 概念: 顾名思义,就是将你输入的文字合成语音,例如: from a ...
- Android 开发 框架系列 百度语音合成
官方文档:http://ai.baidu.com/docs#/TTS-Android-SDK/6d5d6899 官方百度语音合成控制台:https://cloud.baidu.com/product/ ...
- 树莓派3b安装Nginx和php7和百度语音合成模块
1.安装sox系统mp3音频播放模块(项目需要) sudo apt-get install lame sudo apt-get install sox sudo apt-get install lib ...
- Android 百度语音合成集成
一.环境配置: 下载资料:http://ai.baidu.com/sdk 官方视频讲解:http://ai.baidu.com/support/video 接入指南:http://ai.baidu.c ...
- 百度语音合成api/sdk及demo
1.流程 1)换取token 用Api Key 和 SecretKey.访问https://openapi.baidu.com/oauth/2.0/token 换取 token // appKey = ...
- Python实战---制作专属有声小说(调用百度语音合成接口)
这一次的目标是使用百度云的人工智能接口,实现文字转语音的实时转换,将小说文字转换成语音朗读出来. 百度云接口调用 百度的这个接口对于我们普通用户非常友好,他的很多功能都是免费的,而且我们每天可以免费调 ...
- 文本转音频(百度语音合成api)(python)(原创)
应之前的一家小学教育培训机构的要求设计的一款 将文字转音频的程序.(注:后面应该是生成音频才对,没有改过来) 技术难点: ①语音合成,如果没有现在这么多的云服务-百度云语音合成,我估计这个程序会费很大 ...
随机推荐
- LeetCode: Remove Nth Node From End of List 解题报告
Remove Nth Node From End of List Total Accepted: 46720 Total Submissions: 168596My Submissions Quest ...
- Visual Studio 新建项目报错" this template attempted to load component assembly 'NuGet.VisualStudio.Interop, ….".
"Error: this template attempted to load component assembly 'NuGet.VisualStudio.Interop, Version ...
- Flash播放mp4的两个问题:编码问题和需要下载完后才能播放的问题
(1)编码问题.需要是 h.264 编码,不是此编码的在某些Flash版本或OS上会出现放不出来视频的问题:可以用 3GP.MP4视频转换精灵(BRVideoConverter) 转码. (2)下载完 ...
- 移植UE4的模型操作到Unity中
最近在Unity上要写一个东东,功能差不多就是在Unity编辑器上的旋转,移动这些,在手机上也能比较容易操作最好,原来用Axiom3D写过一个类似的,有许多位置并不好用,刚好在研究UE4的源码,在模型 ...
- ROS vpn (pptp) 配置及端口绑定配置
网络搜集 一. 按VPN的协议分类 VPN的隧道协议主要有三种,PPTP,L2TP和IPSec,其中PPTP和L2TP协议工作在OSI模型的第二层,又称为二层隧道协议:IPSec是第三层隧道协议,是最 ...
- CLR VIA
标题 状态 内容 什么是CLR? 什么是托管模块? 托管模块由什么组成? .net代码的执行过程 http://www.cnblogs.com/aaa6818162/p/4726581.ht ...
- Jdbc如何从PostgreSql读取海量数据?PostgreSql源代码分析纪录
前言: 最近做数据同步,需要从PostgreSql获取数据,发现一旦数据比较多,那么读取的速度非常慢,并且内存占用特别多&GC不掉. 代码样例: 为了方便讲解,下面写了事例代码,从b2c_or ...
- android studio ndk使用openMP
好久没碰ndk了,之前都是在eclipse下写makefile配置c++程序的,现在发现主流都是用android studio,eclipse俨然已经被遗弃了,正好最近项目需要用openMP做算法加速 ...
- tengine + mysql + nginx + php
tengine + mysql + nginx + php 1.配置防火墙vim /etc/sysconfig/iptables # 允许80端口通过防火墙-A INPUT -m state --st ...
- Web API 入门系列 - RESTful API 设计指南
参考:https://developer.github.com/v3/ https://github.com/bolasblack/http-api-guide HTTP 协议 目前使用HTTP1. ...