2017 © Pedro Peláez
 

library speechkit-php

Yandex SpeechKit for PHP

image

zloesabo/speechkit-php

Yandex SpeechKit for PHP

  • Thursday, April 28, 2016
  • by ZloeSabo
  • Repository
  • 1 Watchers
  • 8 Stars
  • 495 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 7 % Grown

The README.md

speechkit-php

Build Status Scrutinizer Code Quality Code Coverage, (*1)

Yandex SpeechKit PHP library., (*2)

Installation

SpeechKit uses Composer, please checkout the composer website for more information., (*3)

Add SpeechKit in your composer.json and you can go ahead:, (*4)

composer require zloesabo/speechkit-php

SpeechKit follows the PSR-4 convention names for its classes, which means you can easily integrate SpeechKit classes loading in your own autoloader., (*5)

For users of old version

Usage of previous version is strongly discouraged as it lacked concept and testing. However, if you sure you want to use previous version of library, require it with composer require zloesabo/speechkit-php:~1.0, (*6)

Usage

Simple

// Include dependencies installed with composer
require 'vendor/autoload.php';

use SpeechKit\Response\HypothesesList;
use SpeechKit\Response\Hypothesis;
use SpeechKit\Speech\SpeechContent;
use SpeechKit\SpeechKit;

$key = 'your-key-here';

$speechKit = new SpeechKit($key);

//It can be any type of stream. File, string, instance of StreamInterface, etc.
$source = fopen(__DIR__.'/some/path/to/file.mp3', 'r');

$speech = new SpeechContent($source);

//Defaults will be used: mp3, general topic, russian language
/** @var HypothesesList $result */
$result = $speechKit->recognize($speech);

/** @var Hypothesis $hyphotesis */
foreach ($result as $hyphotesis) {
    echo sprintf(
        'Confidence: %.2f Content: %s',
        $hyphotesis->getConfidence(),
        $hyphotesis->getContent()
    ), PHP_EOL;
}

Advanced


require 'vendor/autoload.php'; use SpeechKit\Client\Curl; use SpeechKit\Response\HypothesesList; use SpeechKit\Response\Hypothesis; use SpeechKit\ResponseParser\SimpleXML; use SpeechKit\Speech\SpeechContent; use SpeechKit\Speech\SpeechContentInterface; use SpeechKit\SpeechKit; use SpeechKit\Uploader\Uploader; use SpeechKit\Uploader\UrlGenerator; $key = 'your-key-here'; $urlGenerator = new UrlGenerator($key); //You could use any type of client which implements ClientInterface $client = new Curl(); $uploader = new Uploader($urlGenerator, $client); //You could use any type of parser which implements ResponseParserInterface $responseParser = new SimpleXML(); $speechKit = new SpeechKit($key, $uploader, $responseParser); $source = fopen(__DIR__.'/some/path/to/file.mp3', 'r'); $speech = new SpeechContent($source); //These settings are default, so you can skip setting them $speech->setContentType(SpeechContentInterface::CONTENT_MP3); $speech->setTopic(SpeechContentInterface::TOPIC_GENERAL); $speech->setLang(SpeechContentInterface::LANG_RU); $speech->setUuid(bin2hex(openssl_random_pseudo_bytes(16))); /** @var HypothesesList $result */ $result = $speechKit->recognize($speech); /** @var Hypothesis $hyphotesis */ foreach ($result as $hyphotesis) { echo sprintf( 'Confidence: %.2f Content: %s', $hyphotesis->getConfidence(), $hyphotesis->getContent() ), PHP_EOL; }

The Versions

28/04 2016

dev-master

9999999-dev

Yandex SpeechKit for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Soynov

yandex speechkit

28/04 2016

2.0.0

2.0.0.0

Yandex SpeechKit for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Soynov

yandex speechkit

28/04 2016

dev-next-version

dev-next-version

Yandex SpeechKit for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Soynov

yandex speechkit

24/07 2015

1.x-dev

1.9999999.9999999.9999999-dev

Yandex SpeechKit for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.2
  • ext-curl *
  • ext-simplexml *

 

by Evgeny Soynov

yandex speechkit

24/07 2015

0.1.0

0.1.0.0

Yandex SpeechKit for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.2
  • ext-curl *
  • ext-simplexml *

 

by Evgeny Soynov

yandex speechkit

24/07 2015

1.0

1.0.0.0

Yandex SpeechKit for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.2
  • ext-curl *
  • ext-simplexml *

 

by Evgeny Soynov

yandex speechkit