- [DEVEXPRESS] Chia sẻ source code cách tạo biểu đồ sơ đồ tổ chức công ty Org Chart trên Winform C#
- [C#] Hướng dẫn tạo Auto Number trên Datagridview winform
- [DATABASE] Hướng dẫn tạo Procedure String Split in Mysql
- [C#] Thiết lập dấu (,) hay dấu (.) ở định dạng số đúng với định dạng số Việt Nam
- [C#] Chia sẻ source code Game Spin Lucky Wheel
- [C#] Hướng dẫn Encode and Decode HTML
- Danh sách tài khoản ChatGPT miễn phí - Hướng dẫn tạo tài khoản Chat Open AI GPT tại Việt Nam
- [C#] Hướng dẫn thay đổi giao diện ứng dụng Winform theo giao diện của Windows
- [VB.NET] Hiệu ứng Acrylic, Mica, Tabbed Blur Effect trên Winform
- [DEVEXPRESS] Hướng dẫn sử dụng HTML Template trên Combobox Edit
- [C#] Chia sẻ source code Orange Rain in Winform
- [DEVEXPRESS] Hướng dẫn sử dụng HTML Template trên XtraMessageBox Winform Devexpress 22.2.3
- [DEVEXPRESS] Hướng dẫn sử dụng HTML and CSS Code Viewer trên Winform
- [C#] Number Effect Counter up and down in winform
- [C#] Hướng dẫn Supend and Resume Process ID in Winform
- [C#] Hiển thị line number trên Richtextbox Winform
- [C#] Fake Blue Screen BSOD in winform
- [C#] Chia sẽ code demo sử dụng Async Parallel Foreach and For in Winform
- [C#] Sử dụng ActionBlock run X task at time winform
- [C#] Hướng dẫn sử dụng Property Grid để lưu và tải lại thông tin cấu hình user trên winform
Lập trình ứng dụng nhận dạng giọng nói (Text To Speed) bằng VB.NET
Hôm nay, mình xin hướng dẫn các bạn, sử dụng thư viện System.speed; có sẵn trong windows, để nhận dạng giọng nói, và thực thi lệnh chúng ta muốn gắn vào. Hiện tại, thì thư viện System.speed, chưa hỗ trợ nhận dạng ngôn ngữ tiếng việt. Chỉ nhận dạng một số giọng nói các nước: English, Denmark, Chinese, Korea, Japanese...
Chương trình ứng dụng như demo bên dưới:
- Đầu tiên, chúng ta cần import thư viện vào.
Imports System.Speech
- Khai báo biến reco để nhận dạng giọng nói
Dim WithEvents reco As New Recognition.SpeechRecognitionEngine
- Viết sự kiện cho form load
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
reco.SetInputToDefaultAudioDevice()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Dim gram As New Recognition.SrgsGrammar.SrgsDocument
Dim colorRule As New Recognition.SrgsGrammar.SrgsRule("color")
Dim colorsList As New Recognition.SrgsGrammar.SrgsOneOf("red", "blue", "white", "gray", "yellow", "close")
colorRule.Add(colorsList)
gram.Rules.Add(colorRule)
gram.Root = colorRule
reco.LoadGrammar(New Recognition.Grammar(gram))
reco.RecognizeAsync()
End Sub
- Viết một sub để set color cho picture box
Private Sub SetColor(ByVal color As System.Drawing.Color)
Dim synth As New Synthesis.SpeechSynthesizer
synth.SpeakAsync("setting the back color to " + color.ToString)
PictureBox1.BackColor = color
End Sub
- Viết sự kiện nhận dạng giọng nói
Private Sub reco_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognitionEventArgs) Handles reco.SpeechRecognized
RichTextBox1.Text = e.Result.Text
Select Case e.Result.Text
Case "red"
SetColor(Color.Red)
Case "blue"
SetColor(Color.Blue)
Case "white"
SetColor(Color.White)
Case "black"
SetColor(Color.Black)
Case "yellow"
SetColor(Color.Yellow)
Case "gray"
SetColor(Color.Gray)
Case "close"
Me.Close()
End Select
End Sub
- Lấy dữ liệu giọng nói hệ thống nhận được
Private Sub reco_RecognizeCompleted(ByVal sender As Object, ByVal e As System.Speech.Recognition.RecognizeCompletedEventArgs) Handles reco.RecognizeCompleted
reco.RecognizeAsync()
End Sub
CHÚC CÁC BẠN THÀNH CÔNG! HÃY NHỚ LIKE AND SHARE NHA CÁC BẠN