在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#多媒体编程 → 【语音朗诵识别】C#科大讯飞源文件

【语音朗诵识别】C#科大讯飞源文件

C#多媒体编程

下载此实例
  • 开发语言:C#
  • 实例大小:1.50M
  • 下载次数:328
  • 浏览次数:3293
  • 发布时间:2017-06-21
  • 实例类别:C#多媒体编程
  • 发 布 人:zjg076000
  • 文件格式:.rar
  • 所需积分:2
 相关标签: C# 文件 c 语音 科大讯飞

实例介绍

【实例简介】

【语音朗诵识别】C#科大讯飞源文件
【实例截图】

C#科大讯飞源文件

介绍:
本案例实现了,语音合成,识别,录音,以及语音朗读功能。

效果图:

科大讯飞.png (6.72 KB, 下载次数: 25)

下载附件

【语音朗诵识别】C#科大讯飞源文件

2014-8-20 23:30 上传



核心调用类预览:

[C#] 纯文本查看 复制代码
?
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Runtime.InteropServices;
usingSystem.IO;
usingSystem.Text;
usingSystem.Threading;
usingNAudio.Wave;
 
namespaceiFlyDotNet
{
    enumErrorCode
    {
        MSP_SUCCESS = 0,
        MSP_ERROR_FAIL = -1,
        MSP_ERROR_EXCEPTION = -2,
 
        /* General errors 10100(0x2774) */
        MSP_ERROR_GENERAL = 10100,        /* 0x2774 */
        MSP_ERROR_OUT_OF_MEMORY = 10101,        /* 0x2775 */
        MSP_ERROR_FILE_NOT_FOUND = 10102,        /* 0x2776 */
        MSP_ERROR_NOT_SUPPORT = 10103,        /* 0x2777 */
        MSP_ERROR_NOT_IMPLEMENT = 10104,        /* 0x2778 */
        MSP_ERROR_ACCESS = 10105,        /* 0x2779 */
        MSP_ERROR_INVALID_PARA = 10106,        /* 0x277A */
        MSP_ERROR_INVALID_PARA_VALUE = 10107,        /* 0x277B */
        MSP_ERROR_INVALID_HANDLE = 10108,        /* 0x277C */
        MSP_ERROR_INVALID_DATA = 10109,        /* 0x277D */
        MSP_ERROR_NO_LICENSE = 10110,        /* 0x277E */
        MSP_ERROR_NOT_INIT = 10111,        /* 0x277F */
        MSP_ERROR_NULL_HANDLE = 10112,        /* 0x2780 */
        MSP_ERROR_OVERFLOW = 10113,        /* 0x2781 */
        MSP_ERROR_TIME_OUT = 10114,        /* 0x2782 */
        MSP_ERROR_OPEN_FILE = 10115,        /* 0x2783 */
        MSP_ERROR_NOT_FOUND = 10116,        /* 0x2784 */
        MSP_ERROR_NO_ENOUGH_BUFFER = 10117,        /* 0x2785 */
        MSP_ERROR_NO_DATA = 10118,        /* 0x2786 */
        MSP_ERROR_NO_MORE_DATA = 10119,        /* 0x2787 */
        MSP_ERROR_SKIPPED = 10120,        /* 0x2788 */
        MSP_ERROR_ALREADY_EXIST = 10121,        /* 0x2789 */
        MSP_ERROR_LOAD_MODULE = 10122,        /* 0x278A */
        MSP_ERROR_BUSY = 10123,        /* 0x278B */
        MSP_ERROR_INVALID_CONFIG = 10124,        /* 0x278C */
        MSP_ERROR_VERSION_CHECK = 10125,        /* 0x278D */
        MSP_ERROR_CANCELED = 10126,        /* 0x278E */
        MSP_ERROR_INVALID_MEDIA_TYPE = 10127,        /* 0x278F */
        MSP_ERROR_CONFIG_INITIALIZE = 10128,        /* 0x2790 */
        MSP_ERROR_CREATE_HANDLE = 10129,        /* 0x2791 */
        MSP_ERROR_CODING_LIB_NOT_LOAD = 10130,        /* 0x2792 */
 
        /* Error codes of network 10200(0x27D8)*/
        MSP_ERROR_NET_GENERAL = 10200,        /* 0x27D8 */
        MSP_ERROR_NET_OPENSOCK = 10201,        /* 0x27D9 */  /* Open socket */
        MSP_ERROR_NET_CONNECTSOCK = 10202,        /* 0x27DA */  /* Connect socket */
        MSP_ERROR_NET_ACCEPTSOCK = 10203,        /* 0x27DB */  /* Accept socket */
        MSP_ERROR_NET_SENDSOCK = 10204,        /* 0x27DC */  /* Send socket data */
        MSP_ERROR_NET_RECVSOCK = 10205,        /* 0x27DD */  /* Recv socket data */
        MSP_ERROR_NET_INVALIDSOCK = 10206,        /* 0x27DE */  /* Invalid socket handle */
        MSP_ERROR_NET_BADADDRESS = 10207,        /* 0x27EF */  /* Bad network address */
        MSP_ERROR_NET_BINDSEQUENCE = 10208,        /* 0x27E0 */  /* Bind after listen/connect */
        MSP_ERROR_NET_NOTOPENSOCK = 10209,        /* 0x27E1 */  /* Socket is not opened */
        MSP_ERROR_NET_NOTBIND = 10210,        /* 0x27E2 */  /* Socket is not bind to an address */
        MSP_ERROR_NET_NOTLISTEN = 10211,        /* 0x27E3 */  /* Socket is not listenning */
        MSP_ERROR_NET_CONNECTCLOSE = 10212,        /* 0x27E4 */  /* The other side of connection is closed */
        MSP_ERROR_NET_NOTDGRAMSOCK = 10213,        /* 0x27E5 */  /* The socket is not datagram type */
 
        /* Error codes of mssp message 10300(0x283C) */
        MSP_ERROR_MSG_GENERAL = 10300,        /* 0x283C */
        MSP_ERROR_MSG_PARSE_ERROR = 10301,        /* 0x283D */
        MSP_ERROR_MSG_BUILD_ERROR = 10302,        /* 0x283E */
        MSP_ERROR_MSG_PARAM_ERROR = 10303,        /* 0x283F */
        MSP_ERROR_MSG_CONTENT_EMPTY = 10304,        /* 0x2840 */
        MSP_ERROR_MSG_INVALID_CONTENT_TYPE = 10305,        /* 0x2841 */
        MSP_ERROR_MSG_INVALID_CONTENT_LENGTH = 10306,        /* 0x2842 */
        MSP_ERROR_MSG_INVALID_CONTENT_ENCODE = 10307,        /* 0x2843 */
        MSP_ERROR_MSG_INVALID_KEY = 10308,        /* 0x2844 */
        MSP_ERROR_MSG_KEY_EMPTY = 10309,        /* 0x2845 */
        MSP_ERROR_MSG_SESSION_ID_EMPTY = 10310,        /* 0x2846 */
        MSP_ERROR_MSG_LOGIN_ID_EMPTY = 10311,        /* 0x2847 */
        MSP_ERROR_MSG_SYNC_ID_EMPTY = 10312,        /* 0x2848 */
        MSP_ERROR_MSG_APP_ID_EMPTY = 10313,        /* 0x2849 */
        MSP_ERROR_MSG_EXTERN_ID_EMPTY = 10314,        /* 0x284A */
        MSP_ERROR_MSG_INVALID_CMD = 10315,        /* 0x284B */
        MSP_ERROR_MSG_INVALID_SUBJECT = 10316,        /* 0x284C */
        MSP_ERROR_MSG_INVALID_VERSION = 10317,        /* 0x284D */
        MSP_ERROR_MSG_NO_CMD = 10318,        /* 0x284E */
        MSP_ERROR_MSG_NO_SUBJECT = 10319,        /* 0x284F */
        MSP_ERROR_MSG_NO_VERSION = 10320,        /* 0x2850 */
        MSP_ERROR_MSG_MSSP_EMPTY = 10321,        /* 0x2851 */
        MSP_ERROR_MSG_NEW_RESPONSE = 10322,        /* 0x2852 */
        MSP_ERROR_MSG_NEW_CONTENT = 10323,        /* 0x2853 */
        MSP_ERROR_MSG_INVALID_SESSION_ID = 10324,        /* 0x2854 */
 
        /* Error codes of DataBase 10400(0x28A0)*/
        MSP_ERROR_DB_GENERAL = 10400,        /* 0x28A0 */
        MSP_ERROR_DB_EXCEPTION = 10401,        /* 0x28A1 */
        MSP_ERROR_DB_NO_RESULT = 10402,        /* 0x28A2 */
        MSP_ERROR_DB_INVALID_USER = 10403,        /* 0x28A3 */
        MSP_ERROR_DB_INVALID_PWD = 10404,        /* 0x28A4 */
        MSP_ERROR_DB_CONNECT = 10405,        /* 0x28A5 */
        MSP_ERROR_DB_INVALID_SQL = 10406,        /* 0x28A6 */
        MSP_ERROR_DB_INVALID_APPID = 10407,       /* 0x28A7 */
 
        /* Error codes of Resource 10500(0x2904)*/
        MSP_ERROR_RES_GENERAL = 10500,        /* 0x2904 */
        MSP_ERROR_RES_LOAD = 10501,        /* 0x2905 */  /* Load resource */
        MSP_ERROR_RES_FREE = 10502,        /* 0x2906 */  /* Free resource */
        MSP_ERROR_RES_MISSING = 10503,        /* 0x2907 */  /* Resource File Missing */
        MSP_ERROR_RES_INVALID_NAME = 10504,        /* 0x2908 */  /* Invalid resource file name */
        MSP_ERROR_RES_INVALID_ID = 10505,        /* 0x2909 */  /* Invalid resource ID */
        MSP_ERROR_RES_INVALID_IMG = 10506,        /* 0x290A */  /* Invalid resource image pointer */
        MSP_ERROR_RES_WRITE = 10507,        /* 0x290B */  /* Write read-only resource */
        MSP_ERROR_RES_LEAK = 10508,        /* 0x290C */  /* Resource leak out */
        MSP_ERROR_RES_HEAD = 10509,        /* 0x290D */  /* Resource head currupt */
        MSP_ERROR_RES_DATA = 10510,        /* 0x290E */  /* Resource data currupt */
        MSP_ERROR_RES_SKIP = 10511,        /* 0x290F */  /* Resource file skipped */
 
        /* Error codes of TTS 10600(0x2968)*/
        MSP_ERROR_TTS_GENERAL = 10600,        /* 0x2968 */
        MSP_ERROR_TTS_TEXTEND = 10601,        /* 0x2969 */ /* Meet text end */
        MSP_ERROR_TTS_TEXT_EMPTY = 10602,        /* 0x296A */ /* no synth text */
 
        /* Error codes of Recognizer 10700(0x29CC) */
        MSP_ERROR_REC_GENERAL = 10700,        /* 0x29CC */
        MSP_ERROR_REC_INACTIVE = 10701,        /* 0x29CD */
        MSP_ERROR_REC_GRAMMAR_ERROR = 10702,        /* 0x29CE */
        MSP_ERROR_REC_NO_ACTIVE_GRAMMARS = 10703,        /* 0x29CF */
        MSP_ERROR_REC_DUPLICATE_GRAMMAR = 10704,        /* 0x29D0 */
        MSP_ERROR_REC_INVALID_MEDIA_TYPE = 10705,        /* 0x29D1 */
        MSP_ERROR_REC_INVALID_LANGUAGE = 10706,        /* 0x29D2 */
        MSP_ERROR_REC_URI_NOT_FOUND = 10707,        /* 0x29D3 */
        MSP_ERROR_REC_URI_TIMEOUT = 10708,        /* 0x29D4 */
        MSP_ERROR_REC_URI_FETCH_ERROR = 10709,        /* 0x29D5 */
 
        /* Error codes of Speech Detector 10800(0x2A30) */
        MSP_ERROR_EP_GENERAL = 10800,        /* 0x2A30 */
        MSP_ERROR_EP_NO_SESSION_NAME = 10801,        /* 0x2A31 */
        MSP_ERROR_EP_INACTIVE = 10802,        /* 0x2A32 */
        MSP_ERROR_EP_INITIALIZED = 10803,        /* 0x2A33 */
 
        /* Error codes of TUV */
        MSP_ERROR_TUV_GENERAL = 10900,        /* 0x2A94 */
        MSP_ERROR_TUV_GETHIDPARAM = 10901,        /* 0x2A95 */  /* Get Busin Param huanid*/
        MSP_ERROR_TUV_TOKEN = 10902,        /* 0x2A96 */  /* Get Token */
        MSP_ERROR_TUV_CFGFILE = 10903,        /* 0x2A97 */  /* Open cfg file */
        MSP_ERROR_TUV_RECV_CONTENT = 10904,        /* 0x2A98 */  /* received content is error */
        MSP_ERROR_TUV_VERFAIL = 10905,        /* 0x2A99 */  /* Verify failure */
 
        /* Error codes of IMTV */
        MSP_ERROR_IMTV_SUCCESS = 11000,        /* 0x2AF8 */  /* 成功 */
        MSP_ERROR_IMTV_NO_LICENSE = 11001,        /* 0x2AF9 */  /* 试用次数结束,用户需要付费 */
        MSP_ERROR_IMTV_SESSIONID_INVALID = 11002,        /* 0x2AFA */  /* SessionId失效,需要重新登录通行证 */
        MSP_ERROR_IMTV_SESSIONID_ERROR = 11003,        /* 0x2AFB */  /* SessionId为空,或者非法 */
        MSP_ERROR_IMTV_UNLOGIN = 11004,        /* 0x2AFC */  /* 未登录通行证 */
        MSP_ERROR_IMTV_SYSTEM_ERROR = 11005,        /* 0x2AFD */  /* 系统错误 */
 
        /* Error codes of HCR */
        MSP_ERROR_HCR_GENERAL = 11100,
        MSP_ERROR_HCR_RESOURCE_NOT_EXIST = 11101,
 
        /* Error codes of http 12000(0x2EE0) */
        MSP_ERROR_HTTP_BASE = 12000,       /* 0x2EE0 */
 
        /*Error codes of ISV */
        MSP_ERROR_ISV_NO_USER = 13000,       /* 32C8 */   /* the user doesn't exist */
    }
 
    #region TTS枚举常量
    /// <summary>
    /// vol参数的枚举常量
    /// </summary>
    publicenumenuVol
    {
        x_soft,
        soft,
        medium,
        loud,
        x_loud
    }
 
    /// <summary>
    /// speed语速参数的枚举常量
    /// </summary>
    publicenumenuSpeed
    {
        x_slow,
        slow,
        medium,
        fast,
        x_fast
    }
    /// <summary>
    /// speeker朗读者枚举常量
    /// </summary>
    publicenumenuSpeeker
    {
        小燕_青年女声_中英文_普通话 = 0,
        小宇_青年男声_中英文_普通话,
        凯瑟琳_青年女声_英语,
        亨利_青年男声_英语,
        玛丽_青年女声_英语,
        小研_青年女声_中英文_普通话,
        小琪_青年女声_中英文_普通话,
        小峰_青年男声_中英文_普通话,
        小梅_青年女声_中英文_粤语,
        小莉_青年女声_中英文_台普,
        小蓉_青年女声_汉语_四川话,
        小芸_青年女声_汉语_东北话,
        小坤_青年男声_汉语_河南话,
        小强_青年男声_汉语_湖南话,
        小莹_青年女声_汉语_陕西话,
        小新_童年男声_汉语_普通话,
        楠楠_童年女声_汉语_普通话,
        老孙_老年男声_汉语_普通话
    }
 
    publicenumSynthStatus
    {
        TTS_FLAG_STILL_HAVE_DATA = 1,
        TTS_FLAG_DATA_END,
        TTS_FLAG_CMD_CANCELED
    }
    #endregion
 
    #region ISR枚举常量
    publicenumAudioStatus
    {
        ISR_AUDIO_SAMPLE_INIT = 0x00,
        ISR_AUDIO_SAMPLE_FIRST = 0x01,
        ISR_AUDIO_SAMPLE_CONTINUE = 0x02,
        ISR_AUDIO_SAMPLE_LAST = 0x04,
        ISR_AUDIO_SAMPLE_SUPPRESSED = 0x08,
        ISR_AUDIO_SAMPLE_LOST = 0x10,
        ISR_AUDIO_SAMPLE_NEW_CHUNK = 0x20,
        ISR_AUDIO_SAMPLE_END_CHUNK = 0x40,
 
        ISR_AUDIO_SAMPLE_VALIDBITS = 0x7f/* to validate the value of sample->status */
    }
 
    publicenumEpStatus
    {
        ISR_EP_NULL = -1,
        ISR_EP_LOOKING_FOR_SPEECH = 0,         ///还没有检测到音频的前端点
        ISR_EP_IN_SPEECH = 1,                  ///已经检测到了音频前端点,正在进行正常的音频处理。
        ISR_EP_AFTER_SPEECH = 3,               ///检测到音频的后端点,后继的音频会被MSC忽略。
        ISR_EP_TIMEOUT = 4,                    ///超时
        ISR_EP_ERROR = 5,                      ///出现错误
        ISR_EP_MAX_SPEECH = 6                  ///音频过大
    }
 
    publicenumRecogStatus
    {
        ISR_REC_NULL = -1,
        ISR_REC_STATUS_SUCCESS = 0,            ///识别成功,此时用户可以调用QISRGetResult来获取(部分)结果。
        ISR_REC_STATUS_NO_MATCH = 1,           ///识别结束,没有识别结果
        ISR_REC_STATUS_INCOMPLETE = 2,         ///正在识别中
        ISR_REC_STATUS_NON_SPEECH_DETECTED = 3,///保留
        ISR_REC_STATUS_SPEECH_DETECTED = 4,    ///发现有效音频
        ISR_REC_STATUS_SPEECH_COMPLETE = 5,    ///识别结束
        ISR_REC_STATUS_MAX_CPU_TIME = 6,       ///保留
        ISR_REC_STATUS_MAX_SPEECH = 7,         ///保留
        ISR_REC_STATUS_STOPPED = 8,            ///保留
        ISR_REC_STATUS_REJECTED = 9,           ///保留
        ISR_REC_STATUS_NO_SPEECH_FOUND = 10    ///没有发现音频
    }
    #endregion
 
    publicclassiFlyTTS
    {
        publicclassJinDuEventArgs : EventArgs
        {
            publicreadonlyintAllLenth;
            publicreadonlyintAllP;
            publicreadonlyintThisLenth;
            publicreadonlyintThisP;
            publicJinDuEventArgs(intallLenth,intallp,intthisLenth,intthisp)
            {
                AllLenth = allLenth;
                AllP = allp;
                ThisLenth = thisLenth;
                ThisP = thisp;
            }
        }
 
        publiceventEventHandler<JinDuEventArgs> Finished;
 
        /// <summary>
        /// 引入TTSDll函数的类
        /// </summary>
        privateclassTTSDll
        {
            #region TTS dll import
 
            [DllImport("msc.dll", CallingConvention = CallingConvention.Cdecl)]
            publicstaticexternintQTTSInit(stringconfigs);
 
            [DllImport("msc.dll", CallingConvention = CallingConvention.Cdecl)]
            publicstaticexternIntPtr QTTSSessionBegin(string_params,refinterrorCode);
 
            [DllImport("msc.dll", CallingConvention = CallingConvention.Cdecl)]
            publicstaticexternintQTTSTextPut(stringsessionID,stringtextString,uinttextLen,string_params);
 
            [DllImport("msc.dll", CallingConvention = CallingConvention.Cdecl)]
            publicstaticexternIntPtr QTTSAudioGet(stringsessionID,refintaudioLen,refSynthStatus synthStatus,refinterrorCode);
 
            [DllImport("msc.dll", CallingConvention = CallingConvention.Cdecl)]
            publicstaticexternIntPtr QTTSAudioInfo(stringsessionID);
 
            [DllImport("msc.dll", CallingConvention = CallingConvention.Cdecl)]
            publicstaticexternintQTTSSessionEnd(stringsessionID,stringhints);
 
            [DllImport("msc.dll", CallingConvention = CallingConvention.Cdecl)]
            publicstaticexternintQTTSGetParam(stringsessionID,stringparamName,stringparamValue,refuintvalueLen);
 
            [DllImport("msc.dll", CallingConvention = CallingConvention.Cdecl)]
            publicstaticexternintQTTSFini();
            #endregion
        }
        privatestringsessionID;
        /// <summary>
        /// 合成音频的采样频率,8000、16000、44100等
        /// </summary>
        publicintrate {get;set; }
 
        /// <summary>
        /// 讯飞的AppID
        /// </summary>
        /// public string appid { get; set; }
 
        privatestring_speed;
        /// <summary>
        /// 语速
        /// </summary>
        publicenuSpeed speed
        {
            get{return(enuSpeed)Enum.Parse(typeof(enuVol), _speed); }
            set{ _speed = value.ToString("G").Replace('_','-'); }
        }
 
        privatestring_vol;
        /// <summary>
        /// 音量
        /// </summary>
        publicenuVol vol
        {
            get{return(enuVol)Enum.Parse(typeof(enuVol), _vol); }
            set{ _vol = value.ToString("G").Replace('_','-'); }
        }
        /// <summary>
        /// 最大音频长度
        /// </summary>
        publiclongmax {get;set; }
 
        publicenuSpeeker speeker
        {
            get{returnspeeker; }
            set{ DSpeeker.TryGetValue(value,out_speeker); }
        }
 
        privatestring_speeker;
         
        privateDictionary<enuSpeeker,string> DSpeeker =newDictionary<enuSpeeker,string>();
 
        privateDictionary<string,string> DSpeekerName =newDictionary<string,string>();
 
        privatebyte[] buffting;
        /// <summary>
        /// 构造函数,初始化引擎
        /// </summary>
        /// <param name="configs">初始化引擎参数</param>
        /// <param name="szParams">开始会话用参数</param>
        publiciFlyTTS(stringconfigs)
        {
            DSpeeker.Add(enuSpeeker.小燕_青年女声_中英文_普通话,"ent=intp65,vcn=xiaoyan");
            DSpeeker.Add(enuSpeeker.小宇_青年男声_中英文_普通话,"ent=intp65,vcn=xiaoyu");
            DSpeeker.Add(enuSpeeker.凯瑟琳_青年女声_英语,"ent=intp65_en,vcn=Catherine");
            DSpeeker.Add(enuSpeeker.亨利_青年男声_英语,"ent=intp65_en,vcn=henry");
            DSpeeker.Add(enuSpeeker.玛丽_青年女声_英语,"ent=vivi21,vcn=vimary");
            DSpeeker.Add(enuSpeeker.小研_青年女声_中英文_普通话,"ent=vivi21,vcn=vixy");
            DSpeeker.Add(enuSpeeker.小琪_青年女声_中英文_普通话,"ent=vivi21,vcn=vixq");
            DSpeeker.Add(enuSpeeker.小峰_青年男声_中英文_普通话,"ent=vivi21,vcn=vixf");
            DSpeeker.Add(enuSpeeker.小梅_青年女声_中英文_粤语,"ent=vivi21,vcn=vixm");
            DSpeeker.Add(enuSpeeker.小莉_青年女声_中英文_台普,"ent=vivi21,vcn=vixl");
            DSpeeker.Add(enuSpeeker.小蓉_青年女声_汉语_四川话,"ent=vivi21,vcn=vixr");
            DSpeeker.Add(enuSpeeker.小芸_青年女声_汉语_东北话,"ent=vivi21,vcn=vixyun");
            DSpeeker.Add(enuSpeeker.小坤_青年男声_汉语_河南话,"ent=vivi21,vcn=vixk");
            DSpeeker.Add(enuSpeeker.小强_青年男声_汉语_湖南话,"ent=vivi21,vcn=vixqa");
            DSpeeker.Add(enuSpeeker.小莹_青年女声_汉语_陕西话,"ent=vivi21,vcn=vixying");
            DSpeeker.Add(enuSpeeker.小新_童年男声_汉语_普通话,"ent=vivi21,vcn=vixx");
            DSpeeker.Add(enuSpeeker.楠楠_童年女声_汉语_普通话,"ent=vivi21,vcn=vinn");
            DSpeeker.Add(enuSpeeker.老孙_老年男声_汉语_普通话,"ent=vivi21,vcn=vils");
 
            DSpeekerName.Add("xiaoyan","ent=intp65,vcn=xiaoyan");
            DSpeekerName.Add("xiaoyu","ent=intp65,vcn=xiaoyu");
            DSpeekerName.Add("catherine","ent=intp65_en,vcn=Catherine");
            DSpeekerName.Add("henry","ent=intp65_en,vcn=henry");
            DSpeekerName.Add("mary","ent=vivi21,vcn=vimary");
            DSpeekerName.Add("xy","ent=vivi21,vcn=vixy");
            DSpeekerName.Add("xq","ent=vivi21,vcn=vixq");
            DSpeekerName.Add("xf","ent=vivi21,vcn=vixf");
            DSpeekerName.Add("xm","ent=vivi21,vcn=vixm");
            DSpeekerName.Add("xl","ent=vivi21,vcn=vixl");
            DSpeekerName.Add("xr","ent=vivi21,vcn=vixr");
            DSpeekerName.Add("xyun","ent=vivi21,vcn=vixyun");
            DSpeekerName.Add("xk","ent=vivi21,vcn=vixk");
            DSpeekerName.Add("xqa","ent=vivi21,vcn=vixqa");
            DSpeekerName.Add("xying","ent=vivi21,vcn=vixying");
            DSpeekerName.Add("xx","ent=vivi21,vcn=vixx");
            DSpeekerName.Add("nn","ent=vivi21,vcn=vinn");
            DSpeekerName.Add("ls","ent=vivi21,vcn=vils");
 
            buffting = iFlyResource.ding;
 
            intret = TTSDll.QTTSInit(configs);
            if(ret != 0)thrownewException("初始化TTS引擎错误,错误代码:" ret);
        }
 
        /// <summary>
        /// 把文字转化为声音,多路配置,多种语音
        /// </summary>
        /// <param name="speekText">要转化成语音的文字</param>
        /// <param name="outWaveFlie">把声音转为文件,默认为不生产wave文件</param>
        publicvoidMultiSpeek(stringSpeekText,stringoutWaveFlie =null)
        {
            System.Console.WriteLine("开始,now=" System.DateTime.Now);
            MemoryStream mStream =newMemoryStream();
            try
            {
                string[] SpeekTexts = System.Text.RegularExpressions.Regex.Split(SpeekText,"\r\n");
                mStream.Write(newbyte[44], 0, 44);
                for(inti = 0; i < SpeekTexts.Length; i )
                {
                     
                    stringThisStr = SpeekTexts[i];
                    ThisStr = ThisStr.Trim();              //去除前后的空白
                    if(ThisStr =="")continue;           //空段的处理
                    intpos = ThisStr.IndexOf('#');        //#在段中的位置
                    if(pos > 0)
                    {
                        //设定了讲话者时用指定的讲话者说
                        DSpeekerName.TryGetValue(ThisStr.Substring(0, pos).ToLower(),out_speeker);
                        speek(ThisStr.Substring(pos 1, ThisStr.Length - pos - 1),refmStream);
                    }
                    else
               


 

实例下载地址

【语音朗诵识别】C#科大讯飞源文件

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警