欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#使用whisper.net實(shí)現(xiàn)語(yǔ)音識(shí)別功能

 更新時(shí)間:2023年11月23日 08:54:14   作者:天天代碼碼天天  
這篇文章主要為大家詳細(xì)介紹了C#如何使用whisper.net實(shí)現(xiàn)語(yǔ)音識(shí)別功能,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,感興趣的小伙伴可以學(xué)習(xí)一下

介紹

github地址:https://github.com/sandrohanea/whisper.net

Whisper.net. Speech to text made simple using Whisper Models

模型下載地址:https://huggingface.co/sandrohanea/whisper.net/tree/main/classic

效果

輸出信息 

whisper_init_from_file_no_state: loading model from 'ggml-small.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 = 768
whisper_model_load: n_audio_head  = 12
whisper_model_load: n_audio_layer = 12
whisper_model_load: n_text_ctx    = 448
whisper_model_load: n_text_state  = 768
whisper_model_load: n_text_head   = 12
whisper_model_load: n_text_layer  = 12
whisper_model_load: n_mels        = 80
whisper_model_load: ftype         = 1
whisper_model_load: qntvr         = 0
whisper_model_load: type          = 3
whisper_model_load: mem required  =  743.00 MB (+   16.00 MB per decoder)
whisper_model_load: adding 1608 extra tokens
whisper_model_load: model ctx     =  464.68 MB
whisper_model_load: model size    =  464.44 MB
whisper_init_state: kv self size  =   15.75 MB
whisper_init_state: kv cross size =   52.73 MB
00:00:00->00:00:20: 皇鶴樓,崔昊,西人已成皇鶴去,此地空于皇鶴樓,皇鶴一去不復(fù)返,白云千載空悠悠。
00:00:20->00:00:39: 青川莉莉漢陽(yáng)樹(shù),方草七七英五周,日暮相關(guān)何處事,燕泊江上世人愁。

項(xiàng)目

代碼

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Whisper.net;
using static System.Net.Mime.MediaTypeNames;
 
namespace C_使用whisper.net實(shí)現(xiàn)語(yǔ)音轉(zhuǎn)文本
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        string fileFilter = "*.wav|*.wav";
        string wavFileName = "";
        WhisperFactory whisperFactory;
        WhisperProcessor processor;
        private async void button2_Click(object sender, EventArgs e)
        {
            if (wavFileName == "")
            {
                return;
            }
 
            try
            {
                button2.Enabled = false;
                using var fileStream = File.OpenRead(wavFileName);
                await foreach (var result in processor.ProcessAsync(fileStream))
                {
                    Console.WriteLine($"{result.Start}->{result.End}: {result.Text}\r\n");
                    txtResult.Text += $"{result.Start}->{result.End}: {result.Text}\r\n";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                button2.Enabled = true;
            }
 
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            whisperFactory = WhisperFactory.FromPath("ggml-small.bin");
 
            processor = whisperFactory.CreateBuilder()
               .WithLanguage("zh")//.WithLanguage("auto")
               .Build();
 
            wavFileName = "085黃鶴樓.wav";
            txtFileName.Text = wavFileName;
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = fileFilter;
            if (ofd.ShowDialog() != DialogResult.OK) return;
 
            txtResult.Text = "";
 
            wavFileName = ofd.FileName;
            txtFileName.Text = wavFileName;
        }
    }
}

到此這篇關(guān)于C#使用whisper.net實(shí)現(xiàn)語(yǔ)音識(shí)別功能的文章就介紹到這了,更多相關(guān)C#語(yǔ)音識(shí)別內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • C#中給Excel添加水印的具體方法

    C#中給Excel添加水印的具體方法

    這篇文章主要介紹了C#中如何給Excel添加水印,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • C#簡(jiǎn)單聊天室雛形

    C#簡(jiǎn)單聊天室雛形

    這篇文章主要為大家詳細(xì)介紹了C#簡(jiǎn)單聊天室雛形,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • C# byte數(shù)組與Image相互轉(zhuǎn)換的方法

    C# byte數(shù)組與Image相互轉(zhuǎn)換的方法

    這篇文章介紹了C# byte數(shù)組與Image相互轉(zhuǎn)換的方法,有需要的朋友可以參考一下
    2013-10-10
  • 淺析C#中g(shù)oto跳轉(zhuǎn)語(yǔ)句的用法

    淺析C#中g(shù)oto跳轉(zhuǎn)語(yǔ)句的用法

    在我們?nèi)粘9ぷ髦谐S玫腃#跳轉(zhuǎn)語(yǔ)句有break、continue、return,但是還有一個(gè)C#跳轉(zhuǎn)語(yǔ)句很多同學(xué)可能都比較的陌生就是goto,下面我們就來(lái)看看goto跳轉(zhuǎn)語(yǔ)句的用法吧
    2024-03-03
  • C#?如何獲取當(dāng)前進(jìn)程或線程的ID

    C#?如何獲取當(dāng)前進(jìn)程或線程的ID

    這篇文章主要介紹了C#?如何獲取當(dāng)前進(jìn)程或線程的ID,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • C#中的高效IO庫(kù)System.IO.Pipelines

    C#中的高效IO庫(kù)System.IO.Pipelines

    這篇文章介紹了C#中的高效IO庫(kù)System.IO.Pipelines,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-07-07
  • 字符串轉(zhuǎn)換成枚舉類型的方法

    字符串轉(zhuǎn)換成枚舉類型的方法

    字符串可以向int, bool等類型轉(zhuǎn)變,但是字符串是否可以向枚舉轉(zhuǎn)變呢?一起看下邊的例子
    2014-01-01
  • C#函數(shù)式程序設(shè)計(jì)之用閉包封裝數(shù)據(jù)的實(shí)現(xiàn)代碼

    C#函數(shù)式程序設(shè)計(jì)之用閉包封裝數(shù)據(jù)的實(shí)現(xiàn)代碼

    如果一個(gè)程序設(shè)計(jì)語(yǔ)言能夠用高階函數(shù)解決問(wèn)題,則意味著數(shù)據(jù)作用域問(wèn)題已十分突出。當(dāng)函數(shù)可以當(dāng)成參數(shù)和返回值在函數(shù)之間進(jìn)行傳遞時(shí),編譯器利用閉包擴(kuò)展變量的作用域,以保證隨時(shí)能得到所需要的數(shù)據(jù)
    2014-03-03
  • 詳解C#中String.ToCharArray方法的使用

    詳解C#中String.ToCharArray方法的使用

    這篇文章主要為大家詳細(xì)介紹了C#中String.ToCharArray方法的使用的相關(guān)知識(shí),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2024-01-01
  • 輕松學(xué)習(xí)C#的ArrayList類

    輕松學(xué)習(xí)C#的ArrayList類

    輕松學(xué)習(xí)C#的ArrayList類,對(duì)C#的ArrayList類感興趣的朋友可以參考本篇文章,幫助大家更靈活的運(yùn)用C#的ArrayList類
    2015-11-11

最新評(píng)論