in pca-server/src/pca/pca-aws-sf-start-transcribe-job.py [0:0]
def evaluate_transcribe_mode(bucket, key):
'''
The user can configure which API and which speaker separation method to use, but this will validate that those
options are valid for the current file and will overrule/downgrade the options. The rules are:
(1) If you ask for speaker-separation and you're not doing ANALYTICS then you get it
(2) If you ask for channel-separation or ANALYTICS but the file is mono then you get STANDARD speaker-separation
(3) If you ask for ANALYTICS on a 2-channel file then it ignores your speaker/channel-separation setting
(4) If the audio has neither 1 nor 2 channels then you get STANDARD API with speaker-separation
@param bucket: Bucket holding the audio file to be tested
@param key: Key for the audio file in the bucket
@return: Transcribe API mode and flag for channel separation
'''
# Determine the correct API and speaker separation that we'll be using
api_mode = cf.appConfig[cf.CONF_TRANSCRIBE_API]
channel_count = count_audio_channels(bucket, key)
channel_mode = cf.appConfig[cf.CONF_SPEAKER_MODE]
if channel_count == 1:
# Mono files are always sent through Standard Transcribe with speaker separation, as using
# either Call Analytics or channel separation will results in sub-standard transcripts
api_mode = cf.API_STANDARD
channel_ident = False
elif channel_count == 2:
# Call Analytics only works on stereo files - if you configure both
# ANALYTICS and SPEAKER_SEPARATION then the ANALYTICS mode wins
if api_mode == cf.API_ANALYTICS:
channel_ident = True
else:
# We're in standard mode with a stereo file - use speaker separation
# if that was configured, otherwise we'll use channel separation
channel_ident = (channel_mode != cf.SPEAKER_MODE_SPEAKER)
else:
# We could have a file with 0 or > 2 channels - default to 1 (but the file will likely break)
api_mode = cf.API_STANDARD
channel_ident = False
return api_mode, channel_ident