• 大小: 28.63MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-06-13
  • 语言: 其他
  • 标签: C#  .NET  tts  语音生成  

资源简介

.NET开发的一个Demo接口,实现功能:tts/语音生成/文本转语音,调用科大讯飞接口,需要替换自己的msc.dll和appID以及文件上传的服务器地址

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;

namespace tts
{
    /// 
    /// text 的摘要说明
    /// 

    public class text2audio : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = “text/plain“;
            string text = context.Request.Form[“text“];
            //string text = context.Request.QueryString[“text“];


            //string text = “test测试音频“;
            //string path = “D:/audios/temp/audioTest23334455.pcm“;

            //保存文件路径(绝对路径)
            string catalog = DateTime.Now.ToString(“yyyyMMdd“);
            string filePath = System.IO.Path.Combine(GetConfigValue(“AudioAbsoluteFolderTemp“) catalog);
            if (!System.IO.Directory.Exists(filePath))
            {
                System.IO.Directory.CreateDirectory(filePath);
            }
            string audioName = CreateFileName(“.wav“);
            string audioPath = System.IO.Path.Combine(filePath  audioName);
            //发音人
            if (context.Request.Form[“speeker“] != null)
            {
                int speekerIndex = int.Parse(context.Request.Form[“speeker“]);
                string speeker = ““;
                switch (speekerIndex)
                {
                    case 0:
                        speeker = “xiaoyan“;
                        break;
                    case 1:
                        speeker = “aisjiuxu“;
                        break;
                    case 2:
                        speeker = “aisxping“;
                        break;
                    case 3:
                        speeker = “aisjinger“;
                        break;
                    case 4:
                        speeker = “aisbabyxu“;
                        break;
                    default:
                        speeker = “xiaoyan“;
                        break;
                }
                Text2Audio(text audioPath speeker);
            }
            else
            {
                Text2Audio(text audioPath);
            }

            //获取(相对路径)
            string relativeUrl = GetConfigValue(“AudioRelativeFolderTemp“);
            string returnURL = System.IO.Path.Combine(relativeUrl catalog audioName).Replace(“\\“ “/“);

            //返回到Response里
            context.Response.Write(returnURL);

        }

        public static String Md5(string s)
        {
            System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);
            bytes = md5.ComputeHash(bytes);
            md5.Clear();
            string ret = ““;
            for (int i = 0; i < bytes.Length; i++)
            {
                ret += Convert.ToStri

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      85773  2019-08-06 11:26  tts\.vs\config\applicationhost.config

    ..A..H.     48128  2019-08-16 11:09  tts\.vs\tts\v15\.suo

     文件          0  2019-08-06 11:26  tts\.vs\tts\v15\Server\sqlite3\db.lock

     文件     733184  2019-08-06 21:09  tts\.vs\tts\v15\Server\sqlite3\storage.ide

     文件      32768  2019-08-16 10:50  tts\.vs\tts\v15\Server\sqlite3\storage.ide-shm

     文件    4124152  2019-08-07 08:48  tts\.vs\tts\v15\Server\sqlite3\storage.ide-wal

     文件       9355  2018-05-24 16:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\.signature.p7s

     文件        271  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Extensions.props

     文件       5530  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props

     文件        275  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.Extensions.props

     文件       5530  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props

     文件       2421  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\content\net45\app.config.install.xdt

     文件        994  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\content\net45\app.config.uninstall.xdt

     文件       2131  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\content\net45\web.config.install.xdt

     文件        742  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\content\net45\web.config.uninstall.xdt

     文件       2432  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\content\net46\app.config.install.xdt

     文件        994  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\content\net46\app.config.uninstall.xdt

     文件       2142  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\content\net46\web.config.install.xdt

     文件        742  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\content\net46\web.config.uninstall.xdt

     文件      40080  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll

     文件       1805  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml

     文件   13116405  2019-08-06 11:27  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0.nupkg

     文件      15976  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\tools\net45\install.ps1

     文件      13832  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\tools\net45\uninstall.ps1

     文件      50032  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\tools\Roslyn45\csc.exe

     文件       1711  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\tools\Roslyn45\csc.exe.config

     文件       1496  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\tools\Roslyn45\csc.rsp

     文件      13680  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\tools\Roslyn45\csi.exe

     文件        253  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\tools\Roslyn45\csi.rsp

     文件     105392  2018-05-24 13:38  tts\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\tools\Roslyn45\Microsoft.Build.Tasks.CodeAnalysis.dll

............此处省略169个文件信息

评论

共有 条评论