bayko/aws-transcribe-multiple-jobs-s3

Not creating unique job names

Closed this issue · 2 comments

Hi,
the code does not create unique names for different jobs, and it is not helping.

Error:

************************************************************
Detected Object: audio/23andme_ceo_empowering_health_mad_money_cnbc.mp3
audio/23andme_ceo_empowering_health_mad_money_cnbc.mp3
audio/23andme_ceo_empowering_health_mad_money_cnbc.mp3
Key matches media format of mp3... creating transcribe job

An error occurred (ConflictException) when calling the StartTranscriptionJob operation: The requested job name already exists. Use a different job name.
************************************************************
Detected Object: audio/2u_ceo_buying_trilogy_and_doubling_our_reach_mad_money_cnbc.mp3
audio/2u_ceo_buying_trilogy_and_doubling_our_reach_mad_money_cnbc.mp3
audio/2u_ceo_buying_trilogy_and_doubling_our_reach_mad_money_cnbc.mp3
Key matches media format of mp3... creating transcribe job

An error occurred (ConflictException) when calling the StartTranscriptionJob operation: The requested job name already exists. Use a different job name.
************************************************************
Detected Object: audio/3m_ceo_addressing_softness_in_china_autos_and_electronics_mad_money_cnbc.mp3
audio/3m_ceo_addressing_softness_in_china_autos_and_electronics_mad_money_cnbc.mp3
audio/3m_ceo_addressing_softness_in_china_autos_and_electronics_mad_money_cnbc.mp3
Key matches media format of mp3... creating transcribe job

An error occurred (ConflictException) when calling the StartTranscriptionJob operation: The requested job name already exists. Use a different job name.
************************************************************
Detected Object: audio/3m_ceo_inge_thulin_secrets_to_relevance_mad_money_cnbc.mp3
audio/3m_ceo_inge_thulin_secrets_to_relevance_mad_money_cnbc.mp3
audio/3m_ceo_inge_thulin_secrets_to_relevance_mad_money_cnbc.mp3
Key matches media format of mp3... creating transcribe job

Can you please suggest edits?

Thanks

I tried to backtrack it and I ended up finding the lines causing the error.

**CODE:**

# Validate key matches correct media format
  if [[ "${KEY,,}" == *"$MEDIA_FORMAT"* ]] > /dev/null 2>&1; then
    echo "Key matches media format of $MEDIA_FORMAT... creating transcribe job"

    # Generate new JSON for transcription job
    TRIM=$(echo $KEY | cut -d "/" -f 3)
    echo $TRIM
    NAME="transcribe-${TRIM%????}"
    echo $NAME
    echo $NAME

**OUTPUT:** 

$ ./transcribe.sh
LOOKING FOR OBJECTS IN PARENT FOLDER
************************************************************
Detected Object: audio/
Key does not match media format of mp3... skipping
************************************************************
Detected Object: audio/1800flowerscom_ceo_enhancing_the_experience_with_ai_mad_money_cnbc.mp3
Key matches media format of mp3... creating transcribe job

transcribe-
transcribe-

An error occurred (ConflictException) when calling the StartTranscriptionJob operation: The requested job name already exists. Use a different job name.
TRIM=$(echo $KEY | cut -d "/" -f 3)

this is producing empty string output

I solved it by replacing:
TRIM=$(echo $KEY | cut -d "/" -f 3)
with
TRIM=$(echo $KEY | cut -d "/" -f 2)