Results 1 to 12 of 12

Thread: Convert Speech to text

  1. #1

    Thread Starter
    Hyperactive Member kuldevbhasin's Avatar
    Join Date
    Mar 2008
    Location
    Mumbai, India
    Posts
    488

    Convert Speech to text

    hi
    i need to develop an app which converts speech to text.
    i need to convert english / hindi / marathi (Indian language) speech to text
    i tried an sample of google api but its paid and i could not understand where to put in my google api.
    i was looking something where in i dont need to pay for each conversion.


    the code i tried is
    Code:
    using NAudio.Wave;
    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 Google.Apis.Auth.OAuth2;
    using Google.Cloud.Speech.V1;
    using Grpc.Auth;
    
    
    //Install-Package Google.Cloud.Speech.V1 -Version 1.0.0-beta08 -Pre
    
    namespace WinRecognize
    {
        public partial class Form1 : Form
        {
    
            private BufferedWaveProvider bwp;
    
            WaveIn waveIn;
            WaveOut waveOut;
            WaveFileWriter writer;
            WaveFileReader reader; 
            string output = "audio.raw";
    
            public Form1()
            {
                InitializeComponent();
    
                waveOut = new WaveOut();
                waveIn = new WaveIn();
    
                waveIn.DataAvailable += new EventHandler<WaveInEventArgs>(waveIn_DataAvailable);
                waveIn.WaveFormat = new NAudio.Wave.WaveFormat(16000, 1);
                bwp = new BufferedWaveProvider(waveIn.WaveFormat);
                bwp.DiscardOnBufferOverflow = true;
    
                btnRecordVoice.Enabled = true;
                btnSave.Enabled = false;
                btnSpeechInfo.Enabled = false;
    
    
    
            }
            
            void waveIn_DataAvailable(object sender, WaveInEventArgs e)
            {
                bwp.AddSamples(e.Buffer, 0, e.BytesRecorded);
    
            }
    
            private void btnRecordVoice_Click(object sender, EventArgs e)
            {
                if (NAudio.Wave.WaveIn.DeviceCount < 1)
                {
                    Console.WriteLine("No microphone!");
                    return;
                }
    
                waveIn.StartRecording();
    
                btnRecordVoice.Enabled = false;
                btnSave.Enabled = true;
                btnSpeechInfo.Enabled = false;
    
            }
    
            private void btnSave_Click(object sender, EventArgs e)
            {
                waveIn.StopRecording();
    
                if (File.Exists("audio.raw"))
                    File.Delete("audio.raw");
    
                writer = new WaveFileWriter(output, waveIn.WaveFormat);
    
                btnRecordVoice.Enabled = false;
                btnSave.Enabled = false;
                btnSpeechInfo.Enabled = true;
    
                byte[] buffer = new byte[bwp.BufferLength];
                int offset = 0;
                int count = bwp.BufferLength;
    
                var read = bwp.Read(buffer, offset, count);
                if (count > 0)
                {
                    writer.Write(buffer, offset, read);
                }
    
                waveIn.Dispose();
                waveIn = null;
                writer.Close();
                writer = null;
                
                reader = new WaveFileReader("audio.raw"); // (new MemoryStream(bytes));
                waveOut.Init(reader);
                waveOut.PlaybackStopped += new EventHandler<StoppedEventArgs>(waveOut_PlaybackStopped);
                waveOut.Play();
                
    
            }
    
            private void waveOut_PlaybackStopped(object sender, StoppedEventArgs e)
            {
                waveOut.Stop();
                reader.Close();
                reader = null;
            }
    
            private void btnSpeechInfo_Click(object sender, EventArgs e)
            {
    
                btnRecordVoice.Enabled = true;
                btnSave.Enabled = false;
                btnSpeechInfo.Enabled = false;
    
                if (File.Exists("audio.raw"))
                {
    
                    var speech = SpeechClient.Create();
                    var response = speech.Recognize(new RecognitionConfig()
                    {
                        Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
                        SampleRateHertz = 16000,
                        LanguageCode = "en",
                    }, RecognitionAudio.FromFile("audio.raw"));
    
    
                    textBox1.Text = "";
    
                    foreach (var result in response.Results)
                    {
                        foreach (var alternative in result.Alternatives)
                        {
                            textBox1.Text = textBox1.Text + " " + alternative.Transcript;
                        }
                    }
    
                    if(textBox1.Text.Length == 0)
                        textBox1.Text = "No Data ";
    
                }
                else
                {
    
                    textBox1.Text = "Audio File Missing ";
    
                }
                
    
            }
    
            private void btnPlayAudio_Click(object sender, EventArgs e)
            {
                if (File.Exists("audio.raw"))
                { 
                    reader = new WaveFileReader("audio.raw"); 
                    waveOut.Init(reader);
                    waveOut.Play();
                }
                else
                {
                    MessageBox.Show("No Audio File Found");
                }
            }
        }
    }
    this is in c# but i can convert it to vb.net but couldnt understand where to set my api key + google api seems to be paid

    pls. guide.
    thanks
    The only time you run out of chances is when you stop taking them.
    The mind is like a parachute.
    It doesn’t work unless it’s open.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Convert Speech to text

    As a .NET developer, it makes sense to use the .NET API that Microsoft provide.

    https://docs.microsoft.com/en-us/azu...es/Speech/Home

  3. #3

    Thread Starter
    Hyperactive Member kuldevbhasin's Avatar
    Join Date
    Mar 2008
    Location
    Mumbai, India
    Posts
    488

    Re: Convert Speech to text

    thanks for ur reply. but it does not support indian language Marathi

    i need conversion of speech in indian languages i.e. Hindi and Marathi to text

    the major part of my speech conversion would be in the Regional Indian Language i.e. Marathi
    The only time you run out of chances is when you stop taking them.
    The mind is like a parachute.
    It doesn’t work unless it’s open.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Convert Speech to text

    Ah, sorry. Didn't take that into account.

  5. #5

    Thread Starter
    Hyperactive Member kuldevbhasin's Avatar
    Join Date
    Mar 2008
    Location
    Mumbai, India
    Posts
    488

    Re: Convert Speech to text

    pls. dont say sorry... at least u replied and guided. if i didnt have marathi conversion then that would have done it i think. thanks
    The only time you run out of chances is when you stop taking them.
    The mind is like a parachute.
    It doesn’t work unless it’s open.

  6. #6

    Thread Starter
    Hyperactive Member kuldevbhasin's Avatar
    Join Date
    Mar 2008
    Location
    Mumbai, India
    Posts
    488

    Re: Convert Speech to text

    anyone has any idea pls ??
    The only time you run out of chances is when you stop taking them.
    The mind is like a parachute.
    It doesn’t work unless it’s open.

  7. #7
    Frenzied Member
    Join Date
    Oct 2012
    Location
    Tampa, FL
    Posts
    1,187

    Re: Convert Speech to text

    Yeah, the language you are trying to convert to/from is sort of 'edge case' in terms of what you would find for free. You might find that some of the paid APIs avaiable only charge after X uses or maybe has a limit of uses per day.

  8. #8

    Thread Starter
    Hyperactive Member kuldevbhasin's Avatar
    Join Date
    Mar 2008
    Location
    Mumbai, India
    Posts
    488

    Re: Convert Speech to text

    Quote Originally Posted by jayinthe813 View Post
    Yeah, the language you are trying to convert to/from is sort of 'edge case' in terms of what you would find for free. You might find that some of the paid APIs avaiable only charge after X uses or maybe has a limit of uses per day.
    thanks for ur reply.
    i am confused at using the Google API too ... where can i get the api key and how to use that ?
    i tried a lot but somehow it is not working at all using the google API i mean. at least for me.
    The only time you run out of chances is when you stop taking them.
    The mind is like a parachute.
    It doesn’t work unless it’s open.

  9. #9

    Thread Starter
    Hyperactive Member kuldevbhasin's Avatar
    Join Date
    Mar 2008
    Location
    Mumbai, India
    Posts
    488

    Re: Convert Speech to text

    anyone to help me out pls
    i am open to developing an web or desktop app ...anything of the 2 is ok so pls. requesting u to guide pls
    The only time you run out of chances is when you stop taking them.
    The mind is like a parachute.
    It doesn’t work unless it’s open.

  10. #10
    New Member
    Join Date
    Jul 2018
    Posts
    3

    Re: Convert Speech to text

    Quote Originally Posted by kuldevbhasin View Post
    anyone to help me out pls
    i am open to developing an web or desktop app ...anything of the 2 is ok so pls. requesting u to guide pls
    Did you ever get this working?

    I am working on using google API to convert audio file to text.
    I have been able to get the authentication working and I believe i am close to getting the program to transcribe the audio to text but not quite/

  11. #11

    Thread Starter
    Hyperactive Member kuldevbhasin's Avatar
    Join Date
    Mar 2008
    Location
    Mumbai, India
    Posts
    488

    Re: Convert Speech to text

    am still stuck at it.
    The only time you run out of chances is when you stop taking them.
    The mind is like a parachute.
    It doesn’t work unless it’s open.

  12. #12
    New Member
    Join Date
    Nov 2019
    Posts
    4

    Re: Convert Speech to text

    Hi did you get any solution. I want to use speech to text in vb6. I tried SAPI but its not working properly.
    Any help would be appreciated. Thank you

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width