GoGreen PC Tune-Up™
Learn More

Insta-Install™
this is how ssl encrypt our websites
MTNCOMP | List View | Table View | myBlog (1834 Entries)
myBlog Home

Blog


ChatGPT create me an AI VB .Net application Teacher to learn Tagalog with voice

by Mountain Computers Inc, Publication Date: Saturday, November 1, 2025

View Count: 289, Keywords: ChatGPT, Tagalog, AI Teacher, Voice, Hashtags: #ChatGPT #Tagalog #AITeacher #Voice



I wanted to learn Tagalog for the last few years, and all the procrastination has lead me to ask ChatGPT to create a Visual Basic .Net application for an AI Teacher to teach me Tagalog.
 
The results were astounding. The following works! Just don't forget your References.
 
more to come...
 
 

 
 
 
Imports System
Imports System.Windows.Forms
Imports System.Text.RegularExpressions
Imports System.Speech.Synthesis

' =========================
' ENTRY POINT
' =========================
Module Program
   
    Sub Main()
        Application.EnableVisualStyles()
        Application.SetCompatibleTextRenderingDefault(False)
        Application.Run(New AITeacherForm())
    End Sub
End Module

' =========================
' MAIN FORM
' =========================
Public Class AITeacherForm
    Inherits Form

    ' === UI Controls ===
    Private inputText As TextBox
    Private outputText As TextBox
    Private directionSelector As ComboBox
    Private explainButton As Button
    Private quizButton As Button
    Private lessonTimePicker As DateTimePicker
    Private enableScheduleCheck As CheckBox
    Private scheduleLabel As Label

    ' === Speech ===
    Private synth As SpeechSynthesizer

    ' === Scheduler ===
    Private lessonTimer As Timer
    Private todayLessonDone As Boolean = False

    Private Enum TranslationDirection
        EnglishToTagalog
        TagalogToEnglish
    End Enum

    Public Sub New()
        Me.Text = "AI Tagalog Teacher (Simplified)"
        Me.Width = 800
        Me.Height = 500
        Me.StartPosition = FormStartPosition.CenterScreen

        InitUi()
        InitSpeech()
        InitScheduler()
    End Sub

    ' =========================
    ' UI SETUP
    ' =========================
    Private Sub InitUi()
        ' Direction selector
        directionSelector = New ComboBox() With {
            .Left = 20,
            .Top = 20,
            .Width = 200,
            .DropDownStyle = ComboBoxStyle.DropDownList
        }
        directionSelector.Items.Add("English → Tagalog")
        directionSelector.Items.Add("Tagalog → English")
        directionSelector.SelectedIndex = 0
        Me.Controls.Add(directionSelector)

        ' Input text
        inputText = New TextBox() With {
            .Left = 20,
            .Top = 60,
            .Width = 740,
            .Height = 80,
            .Multiline = True
        }
        Me.Controls.Add(inputText)

        ' Teach / Translate button
        explainButton = New Button() With {
            .Left = 20,
            .Top = 150,
            .Width = 160,
            .Height = 40,
            .Text = "Teach / Translate"
        }
        AddHandler explainButton.Click, AddressOf ExplainButton_Click
        Me.Controls.Add(explainButton)

        ' Quiz button
        quizButton = New Button() With {
            .Left = 200,
            .Top = 150,
            .Width = 160,
            .Height = 40,
            .Text = "Quiz Me"
        }
        AddHandler quizButton.Click, AddressOf QuizButton_Click
        Me.Controls.Add(quizButton)

        ' Output text
        outputText = New TextBox() With {
            .Left = 20,
            .Top = 210,
            .Width = 740,
            .Height = 150,
            .Multiline = True,
            .ReadOnly = True,
            .BackColor = Drawing.Color.White
        }
        Me.Controls.Add(outputText)

        ' Daily schedule label
        scheduleLabel = New Label() With {
            .Left = 20,
            .Top = 380,
            .Width = 200,
            .Text = "Daily lesson time:"
        }
        Me.Controls.Add(scheduleLabel)

        ' Time picker
        lessonTimePicker = New DateTimePicker() With {
            .Left = 140,
            .Top = 375,
            .Width = 100,
            .Format = DateTimePickerFormat.Time,
            .ShowUpDown = True,
            .Value = DateTime.Today.AddHours(9)
        }
        Me.Controls.Add(lessonTimePicker)

        ' Enable schedule checkbox
        enableScheduleCheck = New CheckBox() With {
            .Left = 260,
            .Top = 377,
            .Width = 200,
            .Text = "Enable daily lesson",
            .Checked = True
        }
        Me.Controls.Add(enableScheduleCheck)
    End Sub

    ' =========================
    ' SPEECH
    ' =========================
    Private Sub InitSpeech()
        Try
            synth = New SpeechSynthesizer()
            synth.SetOutputToDefaultAudioDevice()
        Catch
            ' If System.Speech isn’t available or fails, we just skip audio.
            synth = Nothing
        End Try
    End Sub

    Private Sub Speak(text As String)
        If synth Is Nothing Then Return
        If String.IsNullOrWhiteSpace(text) Then Return

        Try
            synth.SpeakAsyncCancelAll()
            synth.SpeakAsync(text)
        Catch
            ' Ignore TTS errors to keep app stable
        End Try
    End Sub

    ' =========================
    ' SCHEDULER
    ' =========================
    Private Sub InitScheduler()
        lessonTimer = New Timer()
        lessonTimer.Interval = 60 * 1000 ' 1 minute
        AddHandler lessonTimer.Tick, AddressOf LessonTimer_Tick
        lessonTimer.Start()
    End Sub

    Private Sub LessonTimer_Tick(sender As Object, e As EventArgs)
        If Not enableScheduleCheck.Checked Then
            todayLessonDone = False
            Return
        End If

        Dim now As DateTime = DateTime.Now
        Dim lessonTimeToday As DateTime = DateTime.Today.Add(lessonTimePicker.Value.TimeOfDay)

        ' Reset daily flag after date change
        If now.Date > lessonTimeToday.Date Then
            todayLessonDone = False
        End If

        ' Trigger once in a 5-minute window
        If Not todayLessonDone AndAlso now >= lessonTimeToday AndAlso now <= lessonTimeToday.AddMinutes(5) Then
            StartGuidedLesson()
            todayLessonDone = True
        End If
    End Sub

    Private Sub StartGuidedLesson()
        Dim msg As String =
            "Magandang araw! It's time for your Tagalog lesson. " &
            "Type an English phrase or Tagalog phrase and I will translate and explain it."

        outputText.Text = msg
        Speak(msg)
    End Sub

    ' =========================
    ' BUTTON HANDLERS
    ' =========================
    Private Sub ExplainButton_Click(sender As Object, e As EventArgs)
        ' If this is answering a quiz:
        If inputText.Tag IsNot Nothing Then
            CheckQuizAttempt()
            Return
        End If

        Dim text = inputText.Text.Trim()
        If String.IsNullOrWhiteSpace(text) Then Return

        Dim dir As TranslationDirection =
            If(directionSelector.SelectedIndex = 0,
               TranslationDirection.EnglishToTagalog,
               TranslationDirection.TagalogToEnglish)

        ' For now: use offline fallback so you get zero compile errors.
        ' Later you can replace this with real API calls.
        Dim translated = OfflineFallbackTranslate(text, dir)
        Dim explanation = BuildExplanation(text, translated, dir)

        outputText.Text = explanation
        Speak(explanation)
    End Sub

    Private Sub QuizButton_Click(sender As Object, e As EventArgs)
        StartQuizRound()
    End Sub

    ' =========================
    ' QUIZ LOGIC
    ' =========================
    Private Sub StartQuizRound()
        Dim samplePairs As (String, String)() = {
            ("Good morning", "Magandang umaga"),
            ("Thank you", "Salamat"),
            ("How are you?", "Kamusta ka?"),
            ("I love you", "Mahal kita"),
            ("Where is the bathroom?", "Nasaan ang banyo?")
        }

        Dim rnd As New Random()
        Dim pair = samplePairs(rnd.Next(samplePairs.Length))

        Dim askTagalog As Boolean = (rnd.Next(2) = 0)

        Dim question As String
        Dim expected As String

        If askTagalog Then
            question = "Translate to Tagalog: """ & pair.Item1 & """"
            expected = pair.Item2
        Else
            question = "Translate to English: """ & pair.Item2 & """"
            expected = pair.Item1
        End If

        outputText.Text = question
        Speak(question)

        ' Store expected answer in Tag for simple state
        inputText.Clear()
        inputText.Tag = expected
        inputText.Focus()
    End Sub

    Private Sub CheckQuizAttempt()
        Dim expected As String = CStr(inputText.Tag)
        Dim attempt As String = inputText.Text.Trim()
        inputText.Tag = Nothing

        If String.IsNullOrWhiteSpace(attempt) Then
            Return
        End If

        Dim correct As Boolean =
            String.Equals(expected.Trim(), attempt.Trim(), StringComparison.OrdinalIgnoreCase) OrElse
            Normalize(attempt) = Normalize(expected)

        Dim msg As String

        If correct Then
            msg = "Tama! Correct. """ & attempt & """ matches """ & expected & """."
        Else
            msg = "Malapit na. Almost. The expected answer is: """ & expected & """"
        End If

        outputText.Text = msg
        Speak(msg)
    End Sub

    Private Function Normalize(s As String) As String
        s = s.ToLowerInvariant()
        s = Regex.Replace(s, "[^a-záéíóúüñ ]", "")
        Return s.Trim()
    End Function

    ' =========================
    ' TRANSLATION (OFFLINE DEMO)
    ' =========================
    Private Function OfflineFallbackTranslate(text As String, dir As TranslationDirection) As String
        Dim dictEnToTl As New Dictionary(Of String, String)(StringComparer.OrdinalIgnoreCase) From {
            {"hello", "kamusta"},
            {"good morning", "magandang umaga"},
            {"good evening", "magandang gabi"},
            {"thank you", "salamat"},
            {"how are you", "kamusta ka"},
            {"i love you", "mahal kita"}
        }

        Dim dictTlToEn As New Dictionary(Of String, String)(StringComparer.OrdinalIgnoreCase) From {
            {"kamusta", "hello / how are you"},
            {"magandang umaga", "good morning"},
            {"magandang gabi", "good evening"},
            {"salamat", "thank you"},
            {"mahal kita", "i love you"}
        }

        Dim key = text.Trim().ToLowerInvariant()

        If dir = TranslationDirection.EnglishToTagalog Then
            If dictEnToTl.ContainsKey(key) Then
                Return dictEnToTl(key)
            Else
                Return "(No exact offline match. Try a simpler phrase or hook an online dictionary API.)"
            End If
        Else
            If dictTlToEn.ContainsKey(key) Then
                Return dictTlToEn(key)
            Else
                Return "(Walang eksaktong tugma offline. Try another word or enable online API.)"
            End If
        End If
    End Function

    Private Function BuildExplanation(src As String, translated As String, dir As TranslationDirection) As String
        If String.IsNullOrWhiteSpace(translated) Then
            Return ""
        End If

        If translated.StartsWith("("c) Then
            ' It’s already an explanatory message
            Return translated
        End If

        If dir = TranslationDirection.EnglishToTagalog Then
            Return $"In Tagalog, ""{src}"" is ""{translated}"". Ulitin natin: {translated}"
        Else
            Return $"In English, ""{src}"" means ""{translated}"". Sabihin natin: {translated}"
        End If
    End Function

    Private Sub AITeacherForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
End Class


if you found this article helpful, consider contributing $10, 20 an Andrew Jackson or so..to the author. more authors coming soon
FYI we use paypal or patreon, patreon has 3x the transaction fees, so we don't, not yet.

© 2026 myBlog™ v1.2 All rights reserved. We count views as reads, so let's not over think it.