语音合成&语音识别
用微软语音合成功能生成xiaoxiao的语音。
用Whisper离线识别合成的语音输出srt字幕。
一、语音合成
参考这个网址:https://www.bilibili.com/read/cv19064633
合成的音频:晓晓朗读-温柔
二、Whisper 语音识别
下载模型后放入程序目录下:
请注意,主要示例目前仅使用 16 位 WAV 文件运行,因此请确保在运行该工具之前转换您的输入。例如,您可以像这样使用 ffmpeg:
./ffmpeg.exe -i 女孩向男孩表白话-温柔.mp3 -ar 16000 -ac 1 -c:a pcm_s16le 女孩向男孩表白话-温柔.wav
修改示例代码的默认设置:
运行程序,识别结果输出到控制台,也可输出到srt字幕文本:
语音识别视频演示
参考:
模型下载地址:
https://github.com/ggerganov/whisper.cpp/tree/master/models
whisper的C#Demo:
https://github.com/sandrohanea/whisper.net
附录-语音识别结果输出到控制台:
whisper_init_from_file_no_state: loading model from 'ggml-base.bin'
whisper_model_load: loading model
whisper_model_load: n_vocab = 51865
whisper_model_load: n_audio_ctx = 1500
whisper_model_load: n_audio_state = 512
whisper_model_load: n_audio_head = 8
whisper_model_load: n_audio_layer = 6
whisper_model_load: n_text_ctx = 448
whisper_model_load: n_text_state = 512
whisper_model_load: n_text_head = 8
whisper_model_load: n_text_layer = 6
whisper_model_load: n_mels = 80
whisper_model_load: f16 = 1
whisper_model_load: type = 2
whisper_model_load: mem required = 215.00 MB (+ 6.00 MB per decoder)
whisper_model_load: adding 1608 extra tokens
whisper_model_load: model ctx = 140.60 MB
whisper_model_load: model size = 140.54 MB
whisper_init_state: kv self size = 5.25 MB
whisper_init_state: kv cross size = 17.58 MB
whisper_full_with_state: auto-detected language: zh (p = 0.999260)
New Segment: 00:00:00 ==> 00:00:04.0800000 : 曾经我以为这一辈子我都不会再遇到喜欢的人
New Segment: 00:00:04.0800000 ==> 00:00:07.0400000 : 直到遇见你那种心动的感觉
New Segment: 00:00:07.0400000 ==> 00:00:10.3200000 : 我想控制 想忘记 却无能为力
New Segment: 00:00:10.3200000 ==> 00:00:12.2800000 : 与你相处的时间越久
New Segment: 00:00:12.2800000 ==> 00:00:13.9200000 : 对你的喜欢就越深
New Segment: 00:00:13.9200000 ==> 00:00:15.3200000 : 感觉就越强烈
New Segment: 00:00:15.3200000 ==> 00:00:16.8800000 : 你会不会跟我一样
New Segment: 00:00:16.8800000 ==> 00:00:19.6400000 : 遇见你是我最幸福的事情
New Segment: 00:00:19.6400000 ==> 00:00:22.3600000 : 你对我的好 我都记在心里
New Segment: 00:00:22.3600000 ==> 00:00:25.1600000 : 真想不过一切奔向你的怀抱
New Segment: 00:00:25.1600000 ==> 00:00:27.5200000 : 遇见你是我一生的幸运
New Segment: 00:00:27.5200000 ==> 00:00:29.7600000 : 爱上你 是我一生的快乐
New Segment: 00:00:29.7600000 ==> 00:00:32.3600000 : 失去你 是我一生的遗憾
New Segment: 00:00:32.3600000 ==> 00:00:34.2000000 : 我们还能在一起吗
New Segment: 00:00:34.2000000 ==> 00:00:35.8000000 : 早知道喜欢一个人
New Segment: 00:00:35.8000000 ==> 00:00:38.1600000 : 会变得如此悲危和痛苦
New Segment: 00:00:38.1600000 ==> 00:00:40.8800000 : 我宁愿我们从来没有相遇过
New Segment: 00:00:40.8800000 ==> 00:00:42.1200000 : 曾经我以为
New Segment: 00:00:42.1200000 ==> 00:00:45.1600000 : 需要有很多很多的人我才会欢乐
New Segment: 00:00:45.1600000 ==> 00:00:46.5600000 : 直到遇到你以后
New Segment: 00:00:46.5600000 ==> 00:00:48.0800000 : 我知道了只要你一人
New Segment: 00:00:48.0800000 ==> 00:00:49.8400000 : 我边会很幸福
New Segment: 00:00:49.8400000 ==> 00:00:52.3200000 : 只要你愿意 不管什么时候
New Segment: 00:00:52.3200000 ==> 00:00:53.7600000 : 我都会在你身边
New Segment: 00:00:53.7600000 ==> 00:00:55.3200000 : 因为我爱你
New Segment: 00:00:55.3200000 ==> 00:00:57.1200000 : 想和你在一起
New Segment: 00:00:57.1200000 ==> 00:00:59.1200000 : 我不在乎你的收入和地位
New Segment: 00:00:59.1200000 ==> 00:01:01.1600000 : 我只想牵着你的手
New Segment: 00:01:01.1600000 ==> 00:01:03.1600000 : 一起静静地走下去
New Segment: 00:01:03.1600000 ==> 00:01:04.9600000 : 自从那次见了你之后
New Segment: 00:01:04.9600000 ==> 00:01:06.6800000 : 你经常跑到我的梦里
New Segment: 00:01:06.6800000 ==> 00:01:08.4800000 : 害得我心神不明
New Segment: 00:01:08.4800000 ==> 00:01:10.9600000 : 这种感觉 你能理解吗
New Segment: 00:01:10.9600000 ==> 00:01:12.7200000 : 有时候我真想忘了你
New Segment: 00:01:12.7200000 ==> 00:01:14.1200000 : 只记得这个世界
New Segment: 00:01:14.1200000 ==> 00:01:16.6800000 : 然而 我常常忘了整个世界
New Segment: 00:01:16.6800000 ==> 00:01:18 : 只记得你
New Segment: 00:01:18 ==> 00:01:19.4400000 : 当你难过的时候
New Segment: 00:01:19.4400000 ==> 00:01:21.2400000 : 我希望能陪在你身边
New Segment: 00:01:21.2400000 ==> 00:01:23.1600000 : 尽全力让你笑起来
New Segment: 00:01:23.1600000 ==> 00:01:25.2400000 : 我不知道遇见你是对是错
New Segment: 00:01:25.2400000 ==> 00:01:27.9200000 : 但我知道遇见你我开心过
New Segment: 00:01:27.9200000 ==> 00:01:29.1200000 : 这么多年来
New Segment: 00:01:29.1200000 ==> 00:01:31.3600000 : 我一直在寻找理想的爱情
New Segment: 00:01:31.3600000 ==> 00:01:33.2400000 : 但没有一个人能像你那样
New Segment: 00:01:33.2400000 ==> 00:01:35.2400000 : 在最初的时刻打动了我
New Segment: 00:01:35.2400000 ==> 00:01:37.4400000 : 而且越来越深沉的打动
New Segment: 00:01:37.4400000 ==> 00:01:38.8400000 : 我喜欢你
New Segment: 00:01:38.8400000 ==> 00:01:40.3200000 : 就算你脾气不好
New Segment: 00:01:40.3200000 ==> 00:01:41.9200000 : 说话那么难听
New Segment: 00:01:41.9200000 ==> 00:01:43.0400000 : 习惯那么差
New Segment: 00:01:43.0400000 ==> 00:01:44.1200000 : 心那么多情
New Segment: 00:01:44.1200000 ==> 00:01:45.4000000 : 对我那么冷淡
New Segment: 00:01:45.4000000 ==> 00:01:46.5600000 : 不爱说情话
New Segment: 00:01:46.5600000 ==> 00:01:48.2000000 : 我还是喜欢你
New Segment: 00:01:48.2000000 ==> 00:01:49.9600000 : 我知道你很忙
New Segment: 00:01:49.9600000 ==> 00:01:51.2000000 : 不知道为什么
New Segment: 00:01:51.2000000 ==> 00:01:53.0800000 : 总想与你在一起
New Segment: 00:01:53.0800000 ==> 00:01:54.5200000 : 喜欢你的笑容
New Segment: 00:01:54.5200000 ==> 00:01:56.4000000 : 喜欢静静地看着你
New Segment: 00:01:56.4000000 ==> 00:01:58.0800000 : 忽然想不管不顾了
New Segment: 00:01:58.0800000 ==> 00:01:59 : 什么是对
New Segment: 00:01:59 ==> 00:02:00.0400000 : 什么是错
New Segment: 00:02:00.0400000 ==> 00:02:01.5200000 : 只要能和你在一起
New Segment: 00:02:01.5200000 ==> 00:02:03.4000000 : 一切都变得不重要
New Segment: 00:02:03.4000000 ==> 00:02:04.5600000 : 我要你知道
New Segment: 00:02:04.5600000 ==> 00:02:07.4800000 : 这个世界上有一个人会永远等着你
New Segment: 00:02:07.4800000 ==> 00:02:09 : 无论是在什么时候
New Segment: 00:02:09 ==> 00:02:10.8000000 : 无论你在什么地方
New Segment: 00:02:10.8000000 ==> 00:02:12.9200000 : 你知道那个人是谁吗
New Segment: 00:02:12.9200000 ==> 00:02:13.8400000 : 有些话
New Segment: 00:02:13.8400000 ==> 00:02:15.8000000 : 我只对最喜欢的人诉说
New Segment: 00:02:15.8000000 ==> 00:02:17.6800000 : 而你却常常听见
New Segment: 00:02:17.6800000 ==> 00:02:18.8800000 : 在我的心底
New Segment: 00:02:18.8800000 ==> 00:02:20.5200000 : 这世界上有一个
New Segment: 00:02:20.5200000 ==> 00:02:22.1200000 : 对我最重要的名字
New Segment: 00:02:22.1200000 ==> 00:02:24.5200000 : 那个人的名字与你重复
New Segment: 00:02:24.5200000 ==> 00:02:25.8000000 : 我终于发现
New Segment: 00:02:25.8000000 ==> 00:02:27.5200000 : 这世界上有丰厚的爱
New Segment: 00:02:27.5200000 ==> 00:02:28.9600000 : 我不能辜负
New Segment: 00:02:28.9600000 ==> 00:02:30.4000000 : 于是我想对你说
New Segment: 00:02:30.4000000 ==> 00:02:31.2800000 : 我爱你
New Segment: 00:02:31.2800000 ==> 00:02:32.4000000 : 请你轻听
New Segment: 00:02:32.4000000 ==> 00:02:33.2400000 : 我的爱
New Segment: 00:02:33.2400000 ==> 00:02:34.8800000 : 但生在很久很久
New Segment: 00:02:34.8800000 ==> 00:02:36.7200000 : 那个见到你的从前
New Segment: 00:02:36.7200000 ==> 00:02:37.8400000 : 只比为情
New Segment: 00:02:37.8400000 ==> 00:02:38.8000000 : 落指邪你
New Segment: 00:02:38.8000000 ==> 00:02:39.9600000 : 人生浮华
New Segment: 00:02:39.9600000 ==> 00:02:41.0400000 : 岁月一托
New Segment: 00:02:41.0400000 ==> 00:02:42 : 只你一念
New Segment: 00:02:42 ==> 00:02:43.4400000 : 轻是永远
New Segment: 00:02:43.4400000 ==> 00:02:44.9200000 : 可以清楚地回忆起
New Segment: 00:02:44.9200000 ==> 00:02:46.8000000 : 和你在一起的每一个动作
New Segment: 00:02:46.8000000 ==> 00:02:48.0800000 : 每一个表情
New Segment: 00:02:48.0800000 ==> 00:02:49.0800000 : 这些声音
New Segment: 00:02:49.0800000 ==> 00:02:50.1600000 : 这些影响
New Segment: 00:02:50.1600000 ==> 00:02:52.3600000 : 都已经写进我的生命中
New Segment: 00:02:52.3600000 ==> 00:02:53.5600000 : 我不小心把我爱你
New Segment: 00:02:53.5600000 ==> 00:02:54.9600000 : 误发给你了
New Segment: 00:02:54.9600000 ==> 00:02:57.1200000 : 如果你接受那就处存起来
New Segment: 00:02:57.1200000 ==> 00:02:58.4400000 : 如果你不接受
New Segment: 00:02:58.4400000 ==> 00:03:00.6400000 : 就把这三个字反发给我
New Segment: 00:03:00.6400000 ==> 00:03:02.2000000 : 如果有一天
New Segment: 00:03:02.2000000 ==> 00:03:03.7600000 : 我懂了爱情
New Segment: 00:03:03.7600000 ==> 00:03:05.3200000 : 一定是因为你
New Segment: 00:03:05.3200000 ==> 00:03:07.5600000 : 有一种想见不敢见的伤痛
New Segment: 00:03:07.5600000 ==> 00:03:08.6400000 : 这一种喜欢
New Segment: 00:03:08.6400000 ==> 00:03:10.1600000 : 还埋藏在我心中
New Segment: 00:03:10.1600000 ==> 00:03:12.0800000 : 让我对你的怀念越来越浓
New Segment: 00:03:12.0800000 ==> 00:03:14.5600000 : 我却只能把你你放在我心中
New Segment: 00:03:14.5600000 ==> 00:03:17.1200000 : 有很多很多的话想对你说
New Segment: 00:03:17.1200000 ==> 00:03:19 : 有很多很多的无能为力
New Segment: 00:03:19 ==> 00:03:20.6400000 : 想请你来协助处理
New Segment: 00:03:20.6400000 ==> 00:03:22.3200000 : 但最终一句话
New Segment: 00:03:22.3200000 ==> 00:03:24.2000000 : 想你的觉得真好
New Segment: 00:03:24.2000000 ==> 00:03:25.6000000 : 我喜欢你
New Segment: 00:03:25.6000000 ==> 00:03:27.1200000 : 就算你脾气不好
New Segment: 00:03:27.1200000 ==> 00:03:28.4400000 : 说话那么难听
New Segment: 00:03:28.4400000 ==> 00:03:29.6000000 : 习惯那么差
New Segment: 00:03:29.6000000 ==> 00:03:30.7200000 : 心那么多情
New Segment: 00:03:30.7200000 ==> 00:03:31.8800000 : 对我那么冷淡
New Segment: 00:03:31.8800000 ==> 00:03:33.9600000 : 我还是做不到不喜欢你
New Segment: 00:03:33.9600000 ==> 00:03:35.0800000 : 对我来说
New Segment: 00:03:35.0800000 ==> 00:03:37.8400000 : 你的名字跟我爱你是同一个意思
New Segment: 00:03:37.8400000 ==> 00:03:39.6400000 : 在我说你名字的时候
New Segment: 00:03:39.6400000 ==> 00:03:41.3600000 : 总会有我爱你这三个字
New Segment: 00:03:41.3600000 ==> 00:03:43.1600000 : 无声的助解飘出
New Segment: 00:03:43.1600000 ==> 00:03:44.6000000 : 自从你出现后
New Segment: 00:03:44.6000000 ==> 00:03:47.1200000 : 我才知道原来暗恋的滋味那么苦
New Segment: 00:03:47.1200000 ==> 00:03:48.8400000 : 这辈子最疯狂的事
New Segment: 00:03:48.8400000 ==> 00:03:49.9600000 : 就是爱上了你
New Segment: 00:03:49.9600000 ==> 00:03:51.1200000 : 最大的希望
New Segment: 00:03:51.1200000 ==> 00:03:53.2800000 : 就是由你陪我疯一辈子
New Segment: 00:03:53.2800000 ==> 00:03:55.6400000 : 闭上眼以为我能忘记你
New Segment: 00:03:55.6400000 ==> 00:03:58.6400000 : 但留下的眼泪却没有骗到自己
New Segment: 00:03:58.6400000 ==> 00:04:00.2400000 : 为什么婚那么喜欢你
New Segment: 00:04:00.2400000 ==> 00:04:01.1600000 : 你惨了
New Segment: 00:04:01.1600000 ==> 00:04:03.4800000 : 我为了喜欢你都没有时间表白了
New Segment: 00:04:03.4800000 ==> 00:04:04.5600000 : 为了补偿我
New Segment: 00:04:04.5600000 ==> 00:04:06.2800000 : 你必须对我说你爱我
New Segment: 00:04:06.2800000 ==> 00:04:09.9200000 : 不然我一定会疼出时间向你表白的
New Segment: 00:04:09.9200000 ==> 00:04:12.6000000 : 每天都是思念你度过
New Segment: 00:04:12.6000000 ==> 00:04:14.8400000 : 想到你总会有开心的感觉
New Segment: 00:04:14.8400000 ==> 00:04:16.3200000 : 从心底蔓延
New Segment: 00:04:16.3200000 ==> 00:04:18.5600000 : 每天的功课都是想你
New Segment: 00:04:18.5600000 ==> 00:04:19.3600000 : 想你
New Segment: 00:04:19.3600000 ==> 00:04:20.4000000 : 想你
New Segment: 00:04:20.4000000 ==> 00:04:21.4400000 : 我幻想过
New Segment: 00:04:21.4400000 ==> 00:04:23.3200000 : 我们在一起是怎样的
New Segment: 00:04:23.3200000 ==> 00:04:24.4400000 : 你会宠着我
New Segment: 00:04:24.4400000 ==> 00:04:25.2800000 : 爱着我
New Segment: 00:04:25.2800000 ==> 00:04:26.5200000 : 在乎我
New Segment: 00:04:26.5200000 ==> 00:04:27.7200000 : 我也会顺着你
New Segment: 00:04:27.7200000 ==> 00:04:28.6800000 : 体贴你
New Segment: 00:04:28.6800000 ==> 00:04:29.8800000 : 关心你
New Segment: 00:04:29.8800000 ==> 00:04:31.8000000 : 认识你的第一天
New Segment: 00:04:31.8000000 ==> 00:04:33.8000000 : 我就被你的眼神所征服
New Segment: 00:04:33.8000000 ==> 00:04:35.2800000 : 那时候我也知道
New Segment: 00:04:35.2800000 ==> 00:04:36.4400000 : 如果你愿意
New Segment: 00:04:36.4400000 ==> 00:04:38.5200000 : 我将是你一生的服务
New Segment: 00:04:38.5200000 ==> 00:04:40.0400000 : 想听到你的声音
New Segment: 00:04:40.0400000 ==> 00:04:41.8800000 : 记下你说过的美句话
New Segment: 00:04:41.8800000 ==> 00:04:43.6000000 : 想见到你熟悉的脸
New Segment: 00:04:43.6000000 ==> 00:04:45.2000000 : 记下你的温暖微笑
New Segment: 00:04:45.2000000 ==> 00:04:46.9200000 : 想知道你对我的感觉
New Segment: 00:04:46.9200000 ==> 00:04:49.1600000 : 还有想问问看我可以喜欢你吗
New Segment: 00:04:49.1600000 ==> 00:04:50.3200000 : 我不要先花
New Segment: 00:04:50.3200000 ==> 00:04:51.1600000 : 不要掌声
New Segment: 00:04:51.1600000 ==> 00:04:52.9600000 : 我只想让你温暖的怀抱
New Segment: 00:04:52.9600000 ==> 00:04:54.2400000 : 给我一个机会
New Segment: 00:04:54.2400000 ==> 00:04:55.6800000 : 让我住进你的心里
New Segment: 00:04:55.6800000 ==> 00:04:57.1600000 : 听你心跳的声音
New Segment: 00:04:57.1600000 ==> 00:04:58.0800000 : 好不好