Amazon Transcribe Medical Documentation

Version 1.0.0 Last Documentation Update - 14/11/2020

Welcome

Thank you for purchasing Amazon Transcribe Medical PHP Script. We covered almost everything in this document that how easily you can setup this script. We really do appreciate every sale. If you like our work please do not forget to rate it. It helps us in developing new and better cloud solutions.

Author: Berkine
Demo: Amazon Transcribe Medical Demo
Admin Panel: Amazon Transcribe Medical Admin Demo

Requirements

Before installation, your server must have following requirements to run the script properly
  • PHP v7.2 or higher
  • PHP Mbstring Extension
  • PHP PDO Extension
  • PHP JSON Extension
  • PHP CURL Extension
  • Support for MySQL v5.x
  • AWS Account with Root or Admin Level Access
  • AWS IAM User with S3 & Transcribe Read and Write Access

AWS PHP SDK (Version 3)

The AWS PHP SDK v3 comes already included with the script, under - "vendor/aws" folder in the root directory of the app. And it is the offical latest AWS PHP SDK without any modification.

If you prefer to install AWS PHP SDK manually or to update to the latest version, you can get it from here: AWS PHP SDK Download

Installation Instructions

This is a general installation overview of the script, there is a deep dive section provided for each part in the left menu bar.

Follow the steps as explained, and you should be all set. If you face any challenges with installtion steps, reach out to us for a support.

Setup overview:

  • Step 1: Unzip Transcribe Medical to the root directory of your hosting - Ex: /var/www/html/. Which will make it reachable as follows: http://yourwebsitename/transcribe
  • Step 2: After unzipping files, run install.php file to configure your MySQL Database settings.
  • Step 3: (Optional) MySQL Database settings can also be configured manually as explained in notification.php file.
  • Step 4: Import the provided database/import_tables.sql database to the same database that you showed under DB Name in previous steps.
  • Step 5: (Optional) If step 2 was completed successfully and you were redirected to index.php page, you can delete install.php and notification.php files.
  • Step 6: Login into Admin Panel by visiting http://yourwebsitename/transcribe/admin/ page. Use following credentials to login: LOGIN: admin and PASSWORD: 123456. You can change your login and password in Admin Panel as needed.
  • Step 7: Include your AWS IAM Access Key and Secret Access Key Credentials under AWS Configuration page in Admin Panel. If you need to setup AWS Account and S3 bucket, visit AWS Setup page. Make sure you include your S3 Bucket name as well and select correct AWS Region.
  • Step 8: Setup CRON job on your hosting platform, follow the instructions under CRON Setup page.
  • Step 9: If you want to see your Google Analytics data as shown in the demo example, follow the instructions under Google Setup page.
  • Step 10: For seting up SMTP configurations, follow the instructions under PHPMailer Setup page.
  • Step 11: Now you should be all set, enjoy the script!.

File Structure

General overview of included files:
  • Assets - All Client/server CSS and JS files
  • Classes - Entire script was written with OOP approach, all used classes are stored here
  • Core - Core settings and single file for all included files
  • Includes - Helper files for pages to call proper methods and run CRUD for DB
  • Pages - All Admin Panel pages are stored here
	
|   index.php
|   MedicalTranscribe.php
|
+---admin
|   |   footer.php
|   |   header.php
|   |   index.php
|   |   login.php
|   |   logout.php
|   |   navbar.php
|   |
|   +---assets
|   |   +---client
|   |   |   +---css
|   |   |   |       all.min.css
|   |   |   |       awselect.min.css
|   |   |   |       bootstrap.min.css
|   |   |   |       filepond.css
|   |   |   |       flipclock.css
|   |   |   |       fontawesome.min.css
|   |   |   |       green-audio-player.css
|   |   |   |       intro.css
|   |   |   |       medical-icons.css
|   |   |   |       responsive-styles.css
|   |   |   |       styles.css
|   |   |   |
|   |   |   +---img
|   |   |   |       aws-white.png
|   |   |   |       aws.png
|   |   |   |       demo-audio.mp3
|   |   |   |       file.jpg
|   |   |   |       graph.svg
|   |   |   |       mb-bg-fb-04.jpg
|   |   |   |       preload.gif
|   |   |   |       record.png
|   |   |   |       recordz.png
|   |   |   |
|   |   |   +---js
|   |   |   |       awselect.min.js
|   |   |   |       bootstrap.min.js
|   |   |   |       custom.js
|   |   |   |       filepond-plugin-file-validate-size.min.js
|   |   |   |       filepond-plugin-file-validate-type.min.js
|   |   |   |       filepond.jquery.js
|   |   |   |       filepond.js
|   |   |   |       filepond.min.js
|   |   |   |       flipclock.min.js
|   |   |   |       green-audio-player.js
|   |   |   |       jquery-3.5.1.min.js
|   |   |   |       modernizr.js
|   |   |   |       moment.min.js
|   |   |   |       popper.min.js
|   |   |   |       recorder.js
|   |   |   |
|   |   |   \---webfonts
|   |   |           fa-brands-400.eot
|   |   |           fa-brands-400.svg
|   |   |           fa-brands-400.ttf
|   |   |           fa-brands-400.woff
|   |   |           fa-brands-400.woff2
|   |   |           fa-regular-400.eot
|   |   |           fa-regular-400.svg
|   |   |           fa-regular-400.ttf
|   |   |           fa-regular-400.woff
|   |   |           fa-regular-400.woff2
|   |   |           fa-solid-900.eot
|   |   |           fa-solid-900.svg
|   |   |           fa-solid-900.ttf
|   |   |           fa-solid-900.woff
|   |   |           fa-solid-900.woff2
|   |   |           webfont-medical-icons.eot
|   |   |           webfont-medical-icons.svg
|   |   |           webfont-medical-icons.ttf
|   |   |           webfont-medical-icons.woff
|   |   |
|   |   \---server
|   |       +---css
|   |       |       all.min.css
|   |       |       animate.min.css
|   |       |       awselect.min.css
|   |       |       bootstrap.css
|   |       |       bootstrap.css.map
|   |       |       Chart.css
|   |       |       Chart.min.css
|   |       |       datatables.min.css
|   |       |       medical-icons.css
|   |       |       responsive-styles.css
|   |       |       styles.css
|   |       |
|   |       +---img
|   |       |       preload.gif
|   |       |
|   |       +---js
|   |       |       awselect.min.js
|   |       |       bootstrap.bundle.js
|   |       |       bootstrap.bundle.js.map
|   |       |       Chart.bundle.min.js
|   |       |       Chart.min.js
|   |       |       custom.js
|   |       |       datatables.min.js
|   |       |       jquery-3.5.1.min.js
|   |       |       jquery-3.5.1.min.map
|   |       |       loader.js
|   |       |       modernizr.js
|   |       |       moment.min.js
|   |       |       view-selector2.js
|   |       |       view-selector2.js.map
|   |       |
|   |       \---webfonts
|   |               fa-brands-400.eot
|   |               fa-brands-400.svg
|   |               fa-brands-400.ttf
|   |               fa-brands-400.woff
|   |               fa-brands-400.woff2
|   |               fa-regular-400.eot
|   |               fa-regular-400.svg
|   |               fa-regular-400.ttf
|   |               fa-regular-400.woff
|   |               fa-regular-400.woff2
|   |               fa-solid-900.eot
|   |               fa-solid-900.svg
|   |               fa-solid-900.ttf
|   |               fa-solid-900.woff
|   |               fa-solid-900.woff2
|   |               webfont-medical-icons.eot
|   |               webfont-medical-icons.svg
|   |               webfont-medical-icons.ttf
|   |               webfont-medical-icons.woff
|   |
|   +---classes
|   |       CloudWatch.class.php
|   |       Config.class.php
|   |       Cookie.class.php
|   |       DB.class.php
|   |       Email.class.php
|   |       GA.class.php
|   |       Hash.class.php
|   |       Input.class.php
|   |       Redirect.class.php
|   |       S3.class.php
|   |       Session.class.php
|   |       Token.class.php
|   |       TranscribeMedical.class.php
|   |       User.class.php
|   |       Validate.class.php
|   |
|   +---core
|   |       init.core.php
|   |
|   +---database
|   |       import_tables.sql
|   |
|   +---includes
|   |   |   calculatetranscribecost.inc.php
|   |   |   calculatetranscribeseconds.inc.php
|   |   |   changeadsense.inc.php
|   |   |   changeawscredentials.inc.php
|   |   |   changegooglecredentials.inc.php
|   |   |   changepassword.inc.php
|   |   |   changeuploadsettings.inc.php
|   |   |   cron.inc.php
|   |   |   googleanalytics.inc.php
|   |   |   sanitize.inc.php
|   |   |   smtpsettings.inc.php
|   |   |   smtptest.inc.php
|   |   |   tableactions.inc.php
|   |   |   tablefilesprocess.inc.php
|   |   |   tableresultsprocess.inc.php
|   |   |   tabletodaysprocess.inc.php
|   |   |   updateprofile.inc.php
|   |   |
|   |   \---errors
|   |           404.php
|   |
|   +---pages
|   |   +---analytics
|   |   |       analytics.page.php
|   |   |       cloudwatch.page.php
|   |   |
|   |   +---data
|   |   |       files.page.php
|   |   |       results.page.php
|   |   |
|   |   +---marketing
|   |   |       adsense.page.php
|   |   |
|   |   \---settings
|   |           awscredentials.page.php
|   |           google.page.php
|   |           password.page.php
|   |           profile.page.php
|   |           smtp.page.php
|   |           upload.page.php
|   |
|   \---vendor
|       +---aws
|       +---google
|       \---phpmailer
\---pages
        transcribe-file.php
        transcribe-record.php

Database Setup in phpMyAdmin

To run admin panel properly and fetch the application usage data and to set the settings you will need to setup local MySQL database.

All the necessary tables are provided in the root directory of the application, under database folder in a file called database.sql. You will need to import it into your existing or new database.

How to Import Database in phpMyAdmin:

  • Step 1: Login into phpMyAdmin.
  • Step 2: Click on New button to create a new database.
  • Step 3: Provide database name and select utf8_general_ci as collation and click create button.
  • Step 4: After the new database is created, select Import tab and select database.sql file that comes with the application in database folder, and click on Go button.
  • Step 4: Tables in your newly created database should look like this.


After you have your Database Environment setup, run install.php file:

It will create a new file called dbconfig.core.php under admin/core folder..

  • In install.php file:
  • Set mysql db host address.
  • Set mysql db username.
  • Set mysql db password.
  • Set mysql database name.

AWS Account Creation

Getting started with AWS. If you already have AWS Account, skip to next section.

How to Create AWS Account:

  • Step 1: Open the Amazon Web Services home page.
  • Step 2: Choose Create an AWS Account.
    Note: If you signed in to AWS recently, choose Sign in to the Console. If Create a new AWS account isn't visible, first choose Sign in to a different account, and then choose Create a new AWS account.
  • Step 3: Enter your account information, and then choose Continue. Be sure that you enter your account information correctly, especially your email address. If you enter your email address incorrectly, you can't access your account.
  • Step 4: Choose Personal or Professional.
    Note: Personal accounts and professional accounts have the same features and functions.
  • Step 5: Enter your company or personal information.
    Important: For professional AWS accounts, it's a best practice to enter the company phone number rather than a personal cell phone. Configuring a root account with an individual email address or a personal phone number can make your account insecure.
  • Step 6: Read and accept the AWS Customer Agreement.
    Note: Be sure that you read and understand the terms of the AWS Customer Agreement.
  • Step 7: Choose Create Account and Continue.
  • Step 8: On the Payment Information page, enter the information about your payment method, and then choose Verify and Add.
    Note: If you want to use a different billing address for your AWS billing information, choose Use a new address before you choose Verify and Add
    Important: You can't proceed with the sign-up process until you add a valid payment method.
  • Step 9: Verify your phone number. Enter a phone number where you can be reached in the next few minutes.
  • Step 10: In a few moments, an automated system contacts you.
  • Step 11: Enter the PIN you receive, and then choose Continue.
  • Step 12: On the Select a Support Plan page, choose one of the available Support plans. For a description of the available Support plans and their benefits, see Compare AWS Support plans.
  • Step 13: After you choose a Support plan, a confirmation page indicates that your account is being activated. Accounts are usually activated within a few minutes, but the process might take up to 24 hours.
  • Step 14: You can sign in to your AWS account during this time. The AWS home page might display a Complete Sign Up button during this time, even if you've completed all the steps in the sign-up process.
  • Step 15: When your account is fully activated, you receive a confirmation email. Check your email and spam folder for the confirmation email. After you receive this email, you have full access to all AWS services.

AWS IAM User Creation

You will need IAM user with programmatic access and with S3 Read & Write and with Transcribe Policies attached.

Creating AWS IAM Users (via AWS Console):

  • Step 1: Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.
  • Step 2: In the navigation pane, choose Users and then choose Add user.
  • Step 3: Type the user name for the new user. This is the sign-in name for AWS.
    Note: User names can be a combination of up to 64 letters, digits, and these characters: plus (+), equal (=), comma (,), period (.), at sign (@), and hyphen (-). Names must be unique within an account.
  • Step 4: Select the type of access this set of users will have. Select programmatic access.
  • Step 5: Choose Next: Permissions.
  • Step 6: On the Set permissions page, specify how you want to assign permissions to this set of new users. Choose Attach existing policies to user directly
  • Step 7: Seach for AmazonS3FullAccess and select it, search again for AmazonTranscribeFullAccess and select it, afterwards click Next: Review
    Note: If you are familar with IAM Policies, you can create custom policy that will match your needs and security requirements.
  • Step 8: To view the users' access keys (access key IDs and secret access keys), choose Show next to each password and access key that you want to see. To save the access keys, choose Download .csv and then save the file to a safe location.
    Important: This is your only opportunity to view or download the secret access keys, and you must provide this information to your users before they can use the AWS API. Save the user's new access key ID and secret access key in a safe and secure place. You will not have access to the secret keys again after this step.
  • Step 9: Include your Access Key and Secret Access Key to the AWS Credentials Settings tab in the admin panel as shown below.

Include your Access and Secret Access Keys:

AWS Credentials

Amazon S3 Bucket Creation

You will need an S3 Bucket with public read & write access in the region that you prefer.

A bucket is owned by the AWS account that created it. By default, you can create up to 100 buckets in each of your AWS accounts. If you need additional buckets, you can increase your account bucket limit to a maximum of 1,000 buckets by submitting a service limit increase. For information about how to increase your bucket limit, see AWS Service Limits


Create an S3 bucket:

  • Step 1: Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.
  • Step 2: Choose Create bucket.
  • Step 3: Enter Bucket Name and Select AWS Region where you would like to store your files and click Next. Note: Bucket name must be unique at a global level.
  • Step 4: In the next step, you can leave default settings at it is except CloudWatch Request Metrics. If you want to see S3 Bucket Usage details in Admin Panel under CloudWatch tab, select this feature and click Next.
  • Step 5: In the Set Permissions step, you must turn off at least first 2 options or all 4 if you want to make your S3 bucket completely public.
  • Step 6: Review settings and click Create Bucket.
  • Step 7: Include your Bucket Name and Select your AWS Region in the AWS Credentials Settings tab in the admin panel as shown below.

Include your S3 Bucket Name and select your AWS Region where bucket is hosted:

AWS Credentials

Amazon S3 Bucket Configuration

After successfully creating a bucket, add these addtional features for your S3 bucket.

Check following:

  • Make sure your Permissions -> Block Public Access looks at least like this, or has all 4 options turned off.

CRON Job Configuration

To get the results of Amazon Transcribe Medical job you will need to create a cron job since Transcribe processes audio files asynchronously and it might take various time depending on the lenght of the audio file.

How to create simple CRON job:

  • Step 1: Open terminal in your hosting platform.
  • Step 2: Run crontab -e command
  • crontab -e
    
  • Step 3: Enter following cron job, it is scheduled to run every minute, include YOURWEBSITE DOMAIN, you can customize frequency as you prefer:>
  • */1 * * * * curl https://yourwebsite/transcribe/admin/includes/cron.inc.php > /dev/null
    
  • Step 4: You can check all local cron jobs that are running via:
  • crontab -l
    
  • Step 5: As you can see It has a simple job of opening of cron.inc.php file which pull complete transcribe jobs and process as needed.

Google Analytics Tracking Configuration

Analyze in-depth detail about the visitors on your main frontend page.

Setup Google Analytics:

  • Step 1: Visit Google Analytics page.
  • Step 2: On the left menu select Admin.
  • Step 3: Click Create Property, **select Web and then Continue.**.

  • Step 4: After that it will appear screen with information for your website.
  • Step 5: Fill it and then click Create.
  • Step 6: After the tracking site tag is generated, copy and paste Tracking ID into the next step. It will be in the following format - UA-XXXXXXXXX-X
  • Step 7: Include Tracking ID into Google Analytics Tracking ID field in Admin Panel under Google Settings and click Save Changes button.

Google Analytics Service Account

In order to use Google Analytics APIs you will need to enable Google Analytics API and get Service Account credentials in JSON format.

Setup Google Analytics Service Account:

  • Step 1: Go to the Google API Console, click on Library tab on the left. Search for Google Analytics API and Enable it.
  • Step 2: Open the Service accounts page. If prompted, select your existing project or create a new one.
  • Step 3: Click + Create Service Account, enter a name and description for the service account. You can use the default service account ID, or choose a different, unique one. When done click Create.

  • Step 4: After your service account is created, click on Action button(triple dots) and select Create key.
  • Step 5: Select Key type in JSON format and click Create, it will save JSON file on your local file system.
  • Step 6: Upload newly create JSON Key type to Admin Panel under Google Settings as shown below and click Save Changes button.

Google Maps API Key

To use the Maps JavaScript you must have an API key. The API key is a unique identifier that is used to authenticate requests associated with your project for usage and billing purposes.

To Get a Maps API Key:

  • Step 1: Go to the Google API Console
  • Step 2: Click the project drop-down and select or create project for which you want to add an API key and give it a project name.
  • Step 3: If you are using Google API for the first time you will see this screen after creating the project:
  • Step 4: Click Enable Apis and Services button or select Library button on the left.
  • Step 5: Find Maps JavaScript API and enable it as shown below.
  • Step 6: Click the menu button and select Credentials and click Create credentials > API key.
  • Step 7: The API key created dialog displays your newly created API key. Copy and paste it as shown in Step 8. The new API key is listed on the Credentials page under API keys.


    Important: Remember to restrict the API key before using it in production.
  • Step 8: Include the API key in Admin Panel under Google Settings > Google Maps API Key field and click Save Changes button.


Change application restrictions:

Depending on your server/domain configuration the script maybe won't accept the HTTP referrers restrictions so try with changing the application restrictions back to None





Enable Billing on your project:

Sometimes after adding the key these features maybe won't work again. Then depending on the google account associated with the project created and maybe you will need to enable Billing.

Learn more here about it: Billing or here Getting started with Google Maps Platform

Google Adsense Configuration

You can easily include your adsense script with admin panel.

Include Adsense Script:

Copy and paste your script for Left and Right columns in Admin Panel under Google Adsense settings and click save button. Make sure your adsense script has responsive feature turned on.

PHPMailer Configuration

For sending donwload links via email the latest version of PHPMailer is used, included under vendor folder in root directory.

All the SMTP settings can be configured and set in Admin Panel under SMTP Settings.

Required SMTP Settings:
  • SMTP Host
  • SMTP Port
  • SMTP Encryption
  • SMTP EMail Login
  • SMTP EMail Password
You can also add optional SMTP Settings:
  • From Email Address
  • From Name
  • Default Email CC

Include Required SMTP Settings and click Save Changes button:



You can also test your SMTP Settings immediately via Test Email Settings:




If you are planning to use Gmail for sending emails:

In your Gmail Account settings, under Security tab, make sure your Less secure app access feature is turned on.



Upload Configuration

You can configure audio file size and allowed extension via upload settings.

Transcribe Medical Upload Restrictions:

  • Script is set to upload 1 Audio File at a time.
  • Audio file extensions can be one of these: mp3 | mp4 | wav | flac | ogg | amr | webm, add appropriate MIME Types in Upload Settings.
  • Maximum File size can be up to 2GB.
  • Maximum Audio Length can be up to 4 Hours.

Default Settings Change:

You can change all default upload parameters and settings via Admin Panel under Upload Settings tab. Default change takes effect immediately and user will see them upon page refresh.

Accepted File Types has a special format that must be followed:
  • ['audio/mpeg', 'audio/wav', ...] - Exact file types
  • ['audio/*', ...] - Grouped by file type category. IMPORTANT: Might through an error if not supported audio file extension will be used. Make sure upload audio files have one of the supported extensions.

Initial Release v1.0.0

Released on 14th November, 2020