Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add initial transcription module, set language level to 1.8, add GoogleCloudTranscriptionService #55

Merged
merged 8 commits into from
Jul 25, 2017

Conversation

nikvaessen
Copy link
Contributor

@nikvaessen nikvaessen commented Jul 23, 2017

This commit relies on RawStreamListener from libjitsi
@nikvaessen nikvaessen changed the title add initial transcription module, set language level to 1.8 add initial transcription module, set language level to 1.8, add GoogleCloudTranscriptionService Jul 23, 2017
nikvaessen added 2 commits July 23, 2017 12:22
speech-to-text sdk. This Service is currently restricted to 1 minute
@bgrozev
Copy link
Member

bgrozev commented Jul 24, 2017

I would like to make some changes to the names in the API that we added to libjitsi:
RawStreamListener -> ReceiveStreamBufferListener
samplesRead -> handleBuffer
Other suggestions would be welcome, I just really dislike RawStreamListener and samplesRead (which I came up with...) because they are so specific.

Could you open a PR in libjitsi with those changes?

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Star imports please

Copy link
Contributor Author

@nikvaessen nikvaessen Jul 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I always use star imports, or only when I have x of the same package?

* transcriptions. CashedThreadPool is chosen because sending
* audio chunks are small short-lived async tasks.
*/
private ExecutorService executorService = Executors.newCachedThreadPool();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to worry about the requests being sent in order?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not for sendSingleRequest()

* @throws UnsupportedOperationException when this service does not support
* fragmented audio speech-to-text
*/
void sent(TranscriptionRequest request,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to e.g. sendRequest?

Copy link
Contributor Author

@nikvaessen nikvaessen Jul 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will rename it sendSingleRequest to emphasise that this method should be used for one complete audio file/fragment

Participant p = participants.get(ssrc);
if(p != null)
{
participants.get(ssrc).giveBuffer(buffer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why call get() a second time when you already have the result in "p"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we give a reference to "buffer" to another thread, and then we return from samplesRead() which runs in a mixer thread. So two threads have "buffer", which could be a problem (if e.g. the mixer thread decides to re-use the buffer before "our" thread has a chance to run and make a copy. I think the code which makes the copy should run in the mixer thread, and it should submit the task only when it needs to send send a request (this will also have less tasks to submit, since not every Buffer results in a request being sent).

Copy link
Contributor Author

@nikvaessen nikvaessen Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why call get() a second time when you already have the result in "p"?

fixed

I think the code which makes the copy should run in the mixer thread
and it should submit the task only when it needs to send send a request (this will also have less tasks to submit, since not every Buffer results in a request being sent)

Okay, I've moved the local buffering to the mixer thread.

/**
* Whether we should buffer locally before sending
*/
private final Boolean USE_LOCAL_BUFFER = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps make these static? A little explanation of where the numbers come from would be useful: with webrtc we usually see 20ms opus frames which are decoded to 2 bytes per sample and 48000Hz sampling rate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and the aim is to have the buffer store 500ms worth of audio, right?

Copy link
Contributor Author

@nikvaessen nikvaessen Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps make these static?

Made them static and moved the Locale up because inner classes can't have static declarations.

A little explanation of where the numbers come from would be useful: with webrtc we usually see 20ms opus frames which are decoded to 2 bytes per sample and 48000Hz sampling rate.
added

added

Oh, and the aim is to have the buffer store 500ms worth of audio, right?

The aim is indeed to store 500ms to save bandwith. Although this might've been the reason I was seeing some errors yesterday ("The audio was not being received real-time"). Maybe it should be a bit lower

private long ssrc;

/**
* The streaming
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks incomplete

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

*/
void left()
{
session.end();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a null check just in case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@bgrozev
Copy link
Member

bgrozev commented Jul 24, 2017

Merged the PR in libjitsi. You can update the API and use the new maven version: libjitsi-1.0-20170724.205625-298

* TranscriptionResult
*/
@Override
public void sentSingleRequest(final TranscriptionRequest request,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind renaming to "sendSingleRequest" (with a "d")?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@Override
public void give(final TranscriptionRequest request)
{
this.service.submit(() -> requestManager.sentRequest(request));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename to sendRequest (with a "d")?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure sendRequest is a right name either, because we do not necessarily immediately send a request, but I've changed it

@bgrozev bgrozev merged commit 4863d86 into jitsi:master Jul 25, 2017
@nikvaessen nikvaessen deleted the transcription branch July 26, 2017 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants