npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-watson

v1.6.2

Published

React Native module for IBM Watson services

Downloads

40

Readme

react-native-watson

npm version

Overview

React Native module (ios and android) for using select Watson services. Access to Watson services is provided by wrapping the Watson Developer Cloud

Services

Install

npm install --save react-native-watson

Android

Android installation is done with react-native link react-native-watson

minSdkVersion 19 targetSdkVersion 26

iOS

Manually link

Copy RNWatson.m and RNWatson.swift from node_modules/react-native-watson/ios into your project. You will be prompted to create a bridging header. Accept and place the below into the header:

#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>

Dependency Management

We recommend using Carthage to manage dependencies and build the Swift SDK for your application.

You can install Carthage with Homebrew:

$ brew update
$ brew install carthage

Then, navigate to the root directory of your project (where your .xcodeproj file is located) and create an empty Cartfile there:

$ touch Cartfile

To use the Watson Developer Cloud Swift SDK in your application, specify it in your Cartfile:

github "watson-developer-cloud/swift-sdk" == 0.18

Then run the following command to build the dependencies and frameworks:

$ carthage update --platform iOS
Add the Frameworks to your project

Drag-and-drop the built frameworks into your Xcode project (put them in a Frameworks group for better management). You will also need to click on your project in Xcode and go to the General section. Add all of the frameworks to Embedded Binaries.

Note, before you can upload to itunesconnect your will need to strip unwanted architectures from the frameworks. This is done easily with a build script. See the following link for instructions: http://ikennd.ac/blog/2015/02/stripping-unwanted-architectures-from-dynamic-libraries-in-xcode/

Service Instances

Services are instantiated using the IBM Cloud.

Follow these steps to create a service instance and obtain its credentials:

  1. Log in to IBM Cloud at https://www.ibm.com/cloud/.
  2. Create a service instance:
    1. From the Dashboard, select "Use Services or APIs".
    2. Select the service you want to use.
    3. Click "Create".
  3. Copy your service credentials:
    1. Click "Service Credentials" on the left side of the page.
    2. Copy the service's username and password (or api_key for Alchemy).

You will need to provide these service credentials in your application. For example:

TextToSpeech.initialize("your-username-here", "your-password-here")

Note that service credentials are different from your IBM Cloud username and password.

See Getting Started for more information on getting started with the Watson Developer Cloud and IBM Cloud.

Conversation

With the IBM Watson Conversation service you can create cognitive agents--virtual agents that combine machine learning, natural language understanding, and integrated dialog scripting tools to provide outstanding customer engagements.

To use Conversation with React Native, first create your conversation bot and get your workspaceId. Read this quick tutorial on creating a bot.

The following example shows how to start a conversation with the Conversation service:

import { Conversation } from 'react-native-watson'

Conversation.initialize( "user", "password" )
let workspaceId="your_workspace_id"

// To start the conversation, send a message with only the workspaceId
Conversation.message(workspaceId)
            .then(response => {
                console.log(JSON.stringify(response))
                this.setState({output: response.output.text, context: response.context})
            })
            
// To continue a conversation, and send the user's response, send the workspaceId and the input (text and saved context)

let input = {
                text: this.state.text,
                context: this.state.context
            }

Conversation.message(workspaceId, input)
    .then(response => {
        console.log(JSON.stringify(response))
        this.setState({output: response.output.text, context: response.context})
    })

Text to Speech

The IBM Watson Text to Speech service synthesizes natural-sounding speech from input text in a variety of languages and voices that speak with appropriate cadence and intonation.

import {TextToSpeech} from 'react-native-watson';
TextToSpeech.initialize("username", "password")
TextToSpeech.synthesize( "Text to speech, easy" )

Change the voice

TextToSpeech.synthesize( "Text to speech, easy", "en-US_AllisonVoice" )

Get all voices that you can use

TextToSpeech.getVoices()
            .then( voices =>  voices.forEach( voice => console.log(voice.name) ) )

Speech to Text

The IBM Watson Speech to Text service enables you to add speech transcription capabilities to your application. It uses machine intelligence to combine information about grammar and language structure to generate an accurate transcription.

import {SpeechToText} from 'react-native-watson';

SpeechToText.initialize("username", "password")

// will transcribe microphone audio
SpeechToText.startStreaming((error, text) =>
        {
            console.log(text)
        })

SpeechToText.stopStreaming()   

Tone Analyzer

The IBM Watson Tone Analyzer service can be used to discover, understand, and revise the language tones in text. The service uses linguistic analysis to detect three types of tones from written text: emotions, social tendencies, and writing style.

Emotions identified include things like anger, fear, joy, sadness, and disgust. Identified social tendencies include things from the Big Five personality traits used by some psychologists. These include openness, conscientiousness, extraversion, agreeableness, and emotional range. Identified writing styles include confident, analytical, and tentative.

import {ToneAnalyzer} from 'react-native-watson';

ToneAnalyzer.initialize("username", "password")

ToneAnalyzer.getTone( text )
    .then( toneAnalysis => console.log(JSON.stringify(toneAnalysis) )

Natural Language Understanding

Use Natural Language Understanding to analyze various features of text content at scale. Provide text, raw HTML, or a public URL, and IBM Watson Natural Language Understanding will give you results for the features you request. The service cleans HTML content before analysis by default, so the results can ignore most advertisements and other unwanted content.

import { NaturalLanguageUnderstanding } from 'react-native-watson'

NaturalLanguageUnderstanding.initialize( "username", "password" )

let contentToAnalyze = {
            text: "In 2009, Elliot Turner launched AlchemyAPI to process the written word, with all of its quirks and nuances, and got immediate traction."
}

let features = {
    concepts: {
        limit: 5
    },
    categories: true
}

NaturalLanguageUnderstanding.analyzeContent( contentToAnalyze, features )
    .then( results =>
    {
        console.log( JSON.stringify( results, null, "   " )  )
    } )
    .catch( error => {
        console.log( "Error: " + error.message )
    })