1.0.7 • Published 6 years ago

react-ashmanov-services-api v1.0.7

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
6 years ago

Install

$ npm install react-ashmanov-services-api

Import

// use ApiManager for sending requests to Ashmanov Services Server
import { AshServicesApiManager } from 'react-ashmanov-services-api'
// you can use standard components for working with Api
import { AshServicesMicrophone } from 'react-ashmanov-services-api'

Usage

Example

import React, { Component } from 'react';
import { AshServicesApiManager } from 'react-ashmanov-services-api'
import { AshServicesMicrophone } from 'react-ashmanov-services-api'

export default class SpeechRecognitionBoard extends Component {
    constructor(props) {
        super(props);
		this.micText = '';
        this.stopStream = false;
        AshServicesApiManager.setHost('my.domain.com');
    }
    
    render() {
        return (
            <div>
                <AshServicesMicrophone
                    isStopped={ this.stopStream }
                    onStart={(stream) => {
                        AshServicesApiManager.speechRecognitionStream(stream, (text) => {
                            this.micText = text;
                            this.forceUpdate();
                        });
                    }}
                    onFinish={() => {
                        this.stopStream = false;
                    }}
                />
                <div style={{ borderRadius: '5px', background: '#CCCCCC' }}>{ this.micText }</div>
            </div>
        )
    }
}