Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sends json-messages for translations & Sets the participant translati…
…on language on presence update (#124) * Sends json transcript messages in json extension (cherry picked from commit aca02e1) * Rename constant name, log fixes * Removes createEncapsulatingObject, rename variables * Publishes hardcoded translations to the chatroom * Publishes translation results as json-message and minor fixes * Sets the participant translation language on presence update of member * enable translation in config, removes language on removal from presence * Updates pom.xml and minor fix for translation config * Variable synchronizations and code style fixes
- Loading branch information
1 parent
e35b93a
commit aa5d866
Showing
19 changed files
with
701 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/org/jitsi/jigasi/transcription/GoogleCloudTranslationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Jigasi, the JItsi GAteway to SIP. | ||
* | ||
* Copyright @ 2018 Atlassian Pty Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jitsi.jigasi.transcription; | ||
|
||
import com.google.cloud.translate.*; | ||
import com.google.cloud.translate.Translate.*; | ||
|
||
/** | ||
* Implements a {@link TranslationService} which will use Google Cloud | ||
* translate API to translate the given text from one language to another. | ||
* | ||
* Requires google cloud sdk on the machine running the JVM running | ||
* this application. See | ||
* https://cloud.google.com/translate/docs/quickstart | ||
* for details | ||
* | ||
* @author Praveen Kumar Gupta | ||
*/ | ||
public class GoogleCloudTranslationService | ||
implements TranslationService | ||
{ | ||
|
||
/** | ||
* The translation model to be used for translation. | ||
* Possible values are {@code base} and {@code nmt} | ||
*/ | ||
private static final TranslateOption model = TranslateOption.model("nmt"); | ||
|
||
/** | ||
* Translation service object for accessing the cloud translate API. | ||
*/ | ||
private static final Translate translator | ||
= TranslateOptions.getDefaultInstance().getService(); | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String translate(String sourceText, | ||
String sourceLang, String targetLang) | ||
{ | ||
TranslateOption srcLang = TranslateOption.sourceLanguage(sourceLang); | ||
TranslateOption tgtLang = TranslateOption.targetLanguage(targetLang); | ||
|
||
Translation translation = translator.translate( | ||
sourceText, srcLang, tgtLang, model); | ||
|
||
return translation.getTranslatedText(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.