-
Jun 25th, 2018, 10:25 PM
#1
Thread Starter
Hyperactive Member
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.
-
Jun 25th, 2018, 11:51 PM
#2
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
-
Jun 26th, 2018, 10:14 PM
#3
Thread Starter
Hyperactive Member
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.
-
Jun 26th, 2018, 10:23 PM
#4
Re: Convert Speech to text
Ah, sorry. Didn't take that into account.
-
Jun 27th, 2018, 08:17 PM
#5
Thread Starter
Hyperactive Member
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.
-
Jul 3rd, 2018, 04:16 AM
#6
Thread Starter
Hyperactive Member
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.
-
Jul 3rd, 2018, 03:48 PM
#7
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.
-
Jul 4th, 2018, 04:55 PM
#8
Thread Starter
Hyperactive Member
Re: Convert Speech to text
Originally Posted by jayinthe813
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.
-
Jul 17th, 2018, 04:38 AM
#9
Thread Starter
Hyperactive Member
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.
-
Jul 20th, 2018, 12:53 PM
#10
New Member
Re: Convert Speech to text
Originally Posted by kuldevbhasin
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/
-
Nov 28th, 2018, 11:27 PM
#11
Thread Starter
Hyperactive Member
Re: Convert Speech to text
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.
-
Jan 3rd, 2020, 05:08 AM
#12
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|