Skip to content

Commit

Permalink
squash: Fixes formatting and log messages to include context.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Oct 9, 2024
1 parent f3b80d3 commit 0a87a38
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/main/java/org/jitsi/jigasi/TranscriptionGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,15 @@ public class TranscriptionGateway

static {
transcriberClasses.put("GOOGLE", "org.jitsi.jigasi.transcription.GoogleCloudTranscriptionService");
transcriberClasses.put("ORACLE_CLOUD_AI_SPEECH",
"org.jitsi.jigasi.transcription.OracleTranscriptionService");
transcriberClasses.put("ORACLE_CLOUD_AI_SPEECH", "org.jitsi.jigasi.transcription.OracleTranscriptionService");
transcriberClasses.put("EGHT_WHISPER", "org.jitsi.jigasi.transcription.WhisperTranscriptionService");
transcriberClasses.put("VOSK", "org.jitsi.jigasi.transcription.VoskTranscriptionService");

privateKey = JigasiBundleActivator.getConfigurationService().getString(PRIVATE_KEY, null);
privateKeyName = JigasiBundleActivator.getConfigurationService().getString(PRIVATE_KEY_NAME, null);
jwtAudience = JigasiBundleActivator.getConfigurationService().getString(JWT_AUDIENCE, null);
remoteTranscriptionConfigUrl = JigasiBundleActivator.getConfigurationService()
.getString(REMOTE_TRANSCRIPTION_CONFIG_URL, null);
.getString(REMOTE_TRANSCRIPTION_CONFIG_URL, null);
}

/**
Expand Down Expand Up @@ -147,41 +146,41 @@ public void stop()
* it tries to read the transcription.customService property. If
* that also fails it returns the default GoogleCloudTranscriptionService.
*
* @param tenant the tenant which is retrieved from the context
* @param roomJid the roomJid which is retrieved from the context
* @param ctx the context
*/
private String getCustomTranscriptionServiceClass(String tenant, String roomJid)
private String getCustomTranscriptionServiceClass(CallContext ctx)
{
String transcriberClass = null;

if (remoteTranscriptionConfigUrl != null)
{
String tsConfigUrl = remoteTranscriptionConfigUrl + "?conferenceFullName="
+ URLEncoder.encode(roomJid, java.nio.charset.StandardCharsets.UTF_8);
+ URLEncoder.encode(ctx.getRoomJid().toString(), java.nio.charset.StandardCharsets.UTF_8);

transcriberClass = getTranscriberFromRemote(tsConfigUrl);
logger.info("Transcriber class retrieved from remote " + remoteTranscriptionConfigUrl
+ ": " + transcriberClass);
transcriberClass = getTranscriberFromRemote(tsConfigUrl, ctx);
if (logger.isDebugEnabled())
{
logger.debug(ctx + " Transcriber class retrieved from remote "
+ remoteTranscriptionConfigUrl + ": " + transcriberClass);
}
}

if (transcriberClass == null)
{
transcriberClass = JigasiBundleActivator.getConfigurationService()
.getString(
CUSTOM_TRANSCRIPTION_SERVICE_PROP,
null);
logger.info("Transcriber class retrieved from config: " + transcriberClass);
.getString(CUSTOM_TRANSCRIPTION_SERVICE_PROP, null);
logger.info(ctx + " Transcriber class retrieved from config: " + transcriberClass);
}

return transcriberClass;
}

private String getTranscriberFromRemote(String remoteTsConfigUrl)
private String getTranscriberFromRemote(String remoteTsConfigUrl, CallContext ctx)
{
String transcriberClass = null;
if (logger.isDebugEnabled())
{
logger.debug("Calling " + remoteTsConfigUrl + " to retrieve transcriber.");
logger.debug(ctx + " Calling " + remoteTsConfigUrl + " to retrieve transcriber.");
}
try
{
Expand Down Expand Up @@ -211,14 +210,14 @@ private String getTranscriberFromRemote(String remoteTsConfigUrl)
String transcriberType = obj.getString("transcriberType");
if (logger.isDebugEnabled())
{
logger.debug("Retrieved transcriberType: " + transcriberType);
logger.debug(ctx + " Retrieved transcriberType: " + transcriberType);
}
transcriberClass = transcriberClasses.getOrDefault(transcriberType, null);
}
else
{
logger.warn("Could not retrieve transcriber from remote URL " + remoteTsConfigUrl
+ ". Response code: " + responseCode);
logger.warn(ctx + " Could not retrieve transcriber from remote URL " + remoteTsConfigUrl
+ ". Response code: " + responseCode);
}
conn.disconnect();
}
Expand All @@ -232,8 +231,7 @@ private String getTranscriberFromRemote(String remoteTsConfigUrl)
@Override
public TranscriptionGatewaySession createOutgoingCall(CallContext ctx)
{
String customTranscriptionServiceClass = getCustomTranscriptionServiceClass(ctx.getTenant(),
ctx.getRoomJid().toString());
String customTranscriptionServiceClass = getCustomTranscriptionServiceClass(ctx);
AbstractTranscriptionService service = null;
if (customTranscriptionServiceClass != null)
{
Expand Down

0 comments on commit 0a87a38

Please sign in to comment.