GithubHelp home page GithubHelp logo

Comments (10)

asticode avatar asticode commented on May 14, 2024

Your detectVoice function is never called. Is that normal ?Your detectVoice function is never called. Is that normal ?

from go-astideepspeech.

jackleibest avatar jackleibest commented on May 14, 2024

actually it was called by other function whenever the pcm data decoded by ffmpeg

from go-astideepspeech.

asticode avatar asticode commented on May 14, 2024

Can you paste a fully working example that I can run myself ?

from go-astideepspeech.

jackleibest avatar jackleibest commented on May 14, 2024

my code is working on a stream server with ffmpeg sdk, so it can't working stand alone, can you show us an example for live stream translate?

from go-astideepspeech.

asticode avatar asticode commented on May 14, 2024

I've never used the live stream portion of DeepSpeech so I'd need some time to work out an example.

Before that, can you confirm that audio data you're feeding DeepSpeech is 16 bits / 16kHz PCM samples ?

from go-astideepspeech.

jackleibest avatar jackleibest commented on May 14, 2024

yeah, surely, just resample the audio to 16bits / 16kHz pcm data, here is the c lang code for aac to pcm:
static int aacdec_decode(aacdec_t *m, uint8_t *data, int len) {
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = data;
pkt.size = len;
//av_log(m->ctx, AV_LOG_DEBUG, "decode %p\n", m);
int got;
int res = avcodec_decode_audio4(m->ctx, m->f, &got, &pkt);
if(got){
if(m->swr == NULL){
m->src_rate = m->ctx->sample_rate;
m->dst_rate = 16000;
m->swr = swr_alloc();
av_opt_set_int(m->swr, "in_channel_layout", m->ctx->channel_layout, 0);
av_opt_set_int(m->swr, "in_sample_rate", m->src_rate, 0);
av_opt_set_sample_fmt(m->swr, "in_sample_fmt", m->ctx->sample_fmt, 0);
av_opt_set_int(m->swr, "out_channel_layout", AV_CH_LAYOUT_MONO, 0);
av_opt_set_int(m->swr, "out_sample_rate", m->dst_rate, 0);
av_opt_set_sample_fmt(m->swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);
swr_init(m->swr);
}
int dst_linesize;
int dst_nb_channels = av_get_channel_layout_nb_channels(AV_CH_LAYOUT_MONO);
int src_nb_samples = m->f->nb_samples;
m->frameBuff = (uint8_t *)av_malloc(MAX_AUDIO_FRAME_SIZE*2);
int dst_nb_samples = av_rescale_rnd(swr_get_delay(m->swr, m->src_rate) + src_nb_samples, m->dst_rate, m->src_rate, AV_ROUND_UP);
av_samples_alloc_array_and_samples(m->frameBuff, &dst_linesize, dst_nb_channels,dst_nb_samples, AV_SAMPLE_FMT_S16, 0);
int len = swr_convert(m->swr, &m->frameBuff, dst_nb_samples, (const uint8_t **)m->f->data, src_nb_samples);
int total = av_samples_get_buffer_size(&dst_linesize, dst_nb_channels, len, AV_SAMPLE_FMT_S16, 1);
}
av_packet_unref(&pkt);
return res;
}

from go-astideepspeech.

asticode avatar asticode commented on May 14, 2024

What do you get at fmt.Println("result: ", result) ?

Also, what happens if you save all samples to a .wav file and use this lib's cmd to translate it ? In other words, does the non-streaming translation work with your samples ?

from go-astideepspeech.

jackleibest avatar jackleibest commented on May 14, 2024

just get the response: "result: ". I did not try out the non-streaming translation with my samples, because I failed to save the pcm to wav file successfully, but I can play the raw pcm with audacity or ffplay whenever save them to PCM file.

from go-astideepspeech.

asticode avatar asticode commented on May 14, 2024

Thing is, we need to be sure your samples give correct results with the non-streaming part of this lib.

To save your samples to a wav file you can get inspiration from this bit of code.

Once it's done, let me know what results you get from the non-streaming translation.

from go-astideepspeech.

jackleibest avatar jackleibest commented on May 14, 2024

ok, thanks, I will try it in someday, too busy on job things at present.~~

from go-astideepspeech.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.