Skip to content

Sample PHP/Laravel Application to convert Speech to Text using the IBM Watson API

License

Notifications You must be signed in to change notification settings

NdoleStudio/speech-to-text-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo Speech to Text

Sample PHP/Laravel web app that transcribes an audio file into text using the IBM Watson Speech to Text service.

Introduction

Maintainability Test Coverage code style: prettier Build Status

This service service uses IBM's speech recognition capabilities to convert speech in multiple languages into text. The transcription of incoming audio is continuously sent back to the client upon completion. The service is accessed via a REST HTTP interface.

Demo URL: https://audio-to-text.ndolestudio.com

Tech Stack

  • The Frontend of the comes with tailwindcss and Vue.js.

  • The backend is done with PHP using the Laravel Framework

  • PHPUnit is used for both unit tests and integration tests.

    It's advisable to run the tests using docker

Prerequisites

  1. Sign up for an IBM Cloud account.
  2. Create an instance of the Speech to Text service and get your credentials:
    • Go to the Speech to Text page in the IBM Cloud Catalog.
    • Log in to your IBM Cloud account.
    • Click Create.
    • Click Show to view the service credentials.
    • Copy the apikey value, or copy the username and password values if your service instance doesn't provide an apikey.
    • Copy the url value.
  3. Sign up for a Pusher Aaccount
  4. Create a new app on pusher and get your credentials:
    • Log in to your Pusher account.
    • Click Create new app.
    • Set the name of your app and click on the Create my app button
    • Click App Keys to view the app credentials.
    • Copy the app_id, key, secret and cluster values.

Configuring the application

  1. In the application folder, copy the .env.example file and create a file called .env

    cp .env.example .env
    
  2. Open the .env file and add the service credentials that you obtained in the previous step.

    Example .env file that configures the apikey and url for a Speech to Text service instance:

    SPEECH_TO_TEXT_USERNAME=
    SPEECH_TO_TEXT_PASSWORD=
    SPEECH_TO_TEXT_URL=https://stream.watsonplatform.net/speech-to-text/api/v1/recognize
    
  3. Open the .env file and add the service credentials that you obtained in the previous step.

    PUSHER_APP_ID=
    PUSHER_APP_KEY=
    PUSHER_APP_SECRET=
    PUSHER_APP_CLUSTER=
    

Running Locally

Follow the steps below to run this application locally

  1. Clone this git repository and cd into it

    git clone https://github.com/NdoleStudio/speech-to-text-php.git
    
    cd speech-to-text-php
  2. Run the docker container

    docker-compose up --build -d
  3. Open your browser and visit localhost: http://0.0.0.0:8888.

Running Tests

To run tests, setup the application using the setup process shown above and run phpunit inside the workspace container

$ docker exec -it project-workspace /bin/bash
$ phpunit

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details