-
Notifications
You must be signed in to change notification settings - Fork 297
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
Conversation
This commit relies on RawStreamListener from libjitsi
speech-to-text sdk. This Service is currently restricted to 1 minute
the 1 minute limitation
I would like to make some changes to the names in the API that we added to libjitsi: 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Star imports please
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks incomplete
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
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, |
There was a problem hiding this comment.
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")?
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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")?
There was a problem hiding this comment.
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
ac21515
to
f8fd336
Compare
thread, addresses small issues
f8fd336
to
fdd361d
Compare
This PR relies on RawStreamListener from libjitsi