diff --git a/README.md b/README.md index 049e81f..bdbe3ce 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Tatt creates a uniform API for multiple speech-to-text (STT) services. +![demo](demo.gif) + ## Installation pip install tatt diff --git a/demo.gif b/demo.gif new file mode 100644 index 0000000..38e6958 Binary files /dev/null and b/demo.gif differ diff --git a/setup.py b/setup.py index 662cc11..2bf0269 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open('README.md') as file: setup( name="tatt", - version="0.16", + version="0.19", py_modules=['tatt'], url='https://github.com/zevaverbach/tatt', install_requires=[ diff --git a/tatt/config.py b/tatt/config.py index 5fc8a65..37d395c 100644 --- a/tatt/config.py +++ b/tatt/config.py @@ -13,9 +13,9 @@ STT_SERVICES = { AWS_BUCKET_NAME_FMTR_MEDIA = 'tatt-media-{}' AWS_BUCKET_NAME_FMTR_TRANSCRIPT = 'tatt-transcript-{}' -AWS_CREDENTIALS_FILEPATH = ( - os.getenv('AWS_CREDENTIALS_FILEPATH') - or Path.home() / '.aws/credentials' +AWS_CONFIG_FILEPATH = ( + os.getenv('AWS_CONFIG_FILEPATH') + or Path.home() / '.aws/config' ) AWS_REGION = 'us-east-1' diff --git a/tatt/transcribe.py b/tatt/transcribe.py index 5fcfc3d..e9ef3bf 100644 --- a/tatt/transcribe.py +++ b/tatt/transcribe.py @@ -73,7 +73,10 @@ def this(dry_run, media_filepath, service_name): f'No such service! {print_all_services(print_=False)}') service = helpers.get_service(service_name) - s = service(media_filepath) + try: + s = service(media_filepath) + except exceptions.ConfigError as e: + raise click.ClickException(str(e)) if dry_run: print('If this weren\'t a dry run, I would transcribe ' diff --git a/tatt/vendors/amazon.py b/tatt/vendors/amazon.py index 50bc1aa..ab406a5 100644 --- a/tatt/vendors/amazon.py +++ b/tatt/vendors/amazon.py @@ -12,8 +12,9 @@ from tatt import exceptions NAME = 'amazon' BUCKET_NAME_MEDIA = config.AWS_BUCKET_NAME_FMTR_MEDIA.format(NAME) BUCKET_NAME_TRANSCRIPT = config.AWS_BUCKET_NAME_FMTR_TRANSCRIPT.format(NAME) -tr = boto3.client('transcribe') -s3 = boto3.resource('s3') +if check_for_config(): + tr = boto3.client('transcribe') + s3 = boto3.resource('s3') class transcribe: @@ -30,14 +31,13 @@ class transcribe: f"https://s3-{config.AWS_REGION}.amazonaws.com/" f"{self.bucket_names['media']}/{self.basename}") - @staticmethod - def _setup(): - if not check_for_credentials(): + @classmethod + def _setup(cls): + if not check_for_config(): raise exceptions.ConfigError('please run "aws configure" first') - self = transcribe - for bucket_name in self.bucket_names.values(): - if not self.check_for_bucket(bucket_name): - self.make_bucket(bucket_name) + for bucket_name in cls.bucket_names.values(): + if not cls.check_for_bucket(bucket_name): + cls.make_bucket(bucket_name) @staticmethod def check_for_bucket(bucket_name): @@ -73,21 +73,21 @@ class transcribe: ) return job_name - @staticmethod - def get_completed_jobs(job_name_query=None): - return transcribe.get_transcription_jobs( + @classmethod + def get_completed_jobs(cls, job_name_query=None): + return cls.get_transcription_jobs( status='completed', job_name_query=job_name_query) - @staticmethod - def get_pending_jobs(job_name_query=None): - return transcribe.get_transcription_jobs( + @classmethod + def get_pending_jobs(cls, job_name_query=None): + return cls.get_transcription_jobs( status='in_progress', job_name_query=job_name_query) - @staticmethod - def get_all_jobs(job_name_query=None): - return transcribe.get_transcription_jobs(job_name_query) + @classmethod + def get_all_jobs(cls, job_name_query=None): + return cls.get_transcription_jobs(job_name_query) @staticmethod def get_transcription_jobs(status=None, job_name_query=None): @@ -135,8 +135,8 @@ def homogenize_transcription_job_data(transcription_job_data): for jd in transcription_job_data] -def check_for_credentials(): - return config.AWS_CREDENTIALS_FILEPATH.exists() +def check_for_config(): + return config.AWS_CONFIG_FILEPATH.exists() def shell_call(command):