Introduction to Sogou Voice Cloud development--easy to add voice recognition on the mobile side

Source: Internet
Author: User

1 Introduction

Sogou Voice Cloud based on independent development, leading the industry's voice technology, and strive for the vast number of developers to provide the best quality voice services, developers simply integrated voice cloud control, you can call Sogou Voice cloud service through the API, get sogou powerful voice technical support, More focused on the development of business requirements.

2. Services provided

    • Online Speech recognition technology:

The official language: This technology allows the computer to "understand" the human voice, through the machine to turn the voice signal to the corresponding text.

Frankly speaking: is the network to parse speech as text.

    • Offline Speech recognition technology:

Official language: This technology translates speech input recognition into text directly from the local offline voice packet, instead of the cloud Server feature.

Frankly speaking: is offline parsing voice as text, without networking.

    • On-line listening to song Qu Technology:

Official language: This technology is based on Sogou's own technology, to the vast number of small and medium-sized developers to provide free and efficient listening song Qu service. From now on to find the song name does not have to go through the trouble, just record the submitted music clips, by the Sogou Music cloud automatically give the singer and song name.

plainly: is to find Jay Chou's song more difficult to find.

    • Offline Speech synthesis Technology:

The official language: This technology allows the computer to convert external input text information into a natural fluent spoken Chinese, so that the computer has a similar ability to speak like people, offline speech synthesis without relying on the network to synthesize high-quality voice on the device.

plainly: text-to-speech.

3 How to use

Look really tall on Ah, voice service mysterious difficult to understand, now only simple call, where will not adjust where, since mother no longer worry about my study, soeasy!

3.1 Use steps

It 's not difficult to use steps.

First, you need to register a sogou Voice cloud account.

Second, select the service you wish to apply for in the "Application Information" on the left after landing:

, you can also perform a "quick experience". If you are not using Sogou voice cloud service novice, recommended to enter the fast experience area for a quick experience , the advantage is not sogou audit can quickly get appId to invoke the service, the disadvantage is that the number of services limited, but a day This is usually enough:

Click on "My App" in the top right corner to see the appId of the quick request :

    

record number ID information, the service to use Oh!

3.2 Invoking the service

Here's how the client is called to use the "quick experience" application on the "Android" platform using speech recognition as an example.

We first look at Sogou in addition to our appId give us what ...

    

The first one is the SDK package that is called, and the second is the invocation description.

Put the files under the Libs folder in the SDK package:

A brain into your Android project Libs inside, and in the project will sogou-srop.jar introduced Build Path.

Put a button in your layout page:

<span style= "FONT-SIZE:18PX;" ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns:tools= "http// Schemas.android.com/tools "    android:layout_width=" match_parent "    android:layout_height=" Match_parent "    android:paddingbottom= "@dimen/activity_vertical_margin"    android:paddingleft= "@dimen/activity_ Horizontal_margin "    android:paddingright=" @dimen/activity_horizontal_margin "    android:paddingtop=" @dimen /activity_vertical_margin "    tools:context=" com.example.testyuyin.mainactivity$placeholderfragment ">    <button        android:id= "@+id/button"        android:layout_width= "wrap_content"        android:layout_height= " Wrap_content "        android:text=" I want to talk! "/></relativelayout></span>

The calling code in the activity:

<span style= "FONT-SIZE:18PX;" >package com.example.testyuyin;import java.util.list;import Android.app.activity;import android.app.AlertDialog ; Import Android.app.fragment;import Android.content.dialoginterface;import Android.os.bundle;import Android.view.layoutinflater;import Android.view.menu;import Android.view.menuitem;import Android.view.View;import Android.view.view.onclicklistener;import Android.view.viewgroup;import Android.widget.arrayadapter;import Android.widget.button;import Android.widget.textview;import Com.sogou.speech.listener.recognizerlistener;import Com.sogou.speech.ui.recognizerdialog;public class Mainactivity extends Activity {public static Recognizerdialog dialog ; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.activity_main); if (savedinstancestate = = null) {Getfragmentmanager (). BeginTransaction (). Add ( R.id.container, New Placeholderfragment ()). commit ();}} @Overridepublic Boolean OncreateoptioNsmenu (Menu menu) {//Inflate the menu; This adds items to the action bar if it is present.getmenuinflater (). Inflate (r.men U.main, menu); return true;} @Overridepublic boolean onoptionsitemselected (MenuItem Item) {//Handle Action Bar item clicks here. The action bar will//automatically handle clicks on the Home/up button so long//as you specify a parent activity in and RoidManifest.xml.int id = item.getitemid (); if (id = = r.id.action_settings) {return true;} return super.onoptionsitemselected (item);} /** * A placeholder fragment containing a simple view. */public Static class Placeholderfragment extends Fragment {public placeholderfragment () {} @Overridepublic View Oncreateview (Layoutinflater inflater, ViewGroup container,bundle savedinstancestate) {View RootView = inflater.inflate (R.layout.fragment_main, Container,false); Button button = (button) Rootview.findviewbyid (R.id.button);d ialog = new Recognizerdialog (getactivity (), "AppId", " AccessKey ", True, False);d Ialog.setlistener (New RecognizErlistener () {@Overridepublic void Onresults (list<list<string>> arg0) {for (list<string> stringlist : arg0) {System.out.println ("Yuyin------------------"), for (String s:stringlist) {System.out.println ("Yuyin:" + s);}} string[] ss = new String[arg0.get (0). Size ()];for (int i = 0; i < ss.length; i++) {Ss[i] = arg0.get (0). get (i);} New Alertdialog.builder (Getactivity ()). Settitle ("You said:"). Setsinglechoiceitems (SS, 0,new Dialoginterface.onclicklistener () {@Overridepublic void OnClick (Dialoginterface dialog,int which) {Dialog.dismiss ();}}). Setnegativebutton ("Cancel", null). Show (); @Overridepublic void onquitquietly (int arg0) {//TODO auto-generated method stub} @Overridepublic void Onpartresults (List <List<String>> arg0) {//Todo auto-generated method stub} @Overridepublic void OnError (int arg0) {//Todo auto- Generated method stub}}); Button.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View v) { Dialog.show ();}}); return Rootview;}}} </span> 

Did you see that? We first define a dialog, which is a voice dialog box that references the Sogou voice. Then set up a listenerfor dialog: Recognizerlistener, which monitors the user's voice behavior. Note "AppId" and "AccessKey" are replaced with the values obtained after the request . Of course, there are some callback functions to implement.

Inside the function onresults, we can define the behavior after getting the speech result. Let's take a look at the Onresults function:

<span style= "FONT-SIZE:18PX;" >public void Onresults (list<list<string>> arg0) </span>

You can see that its function is a two-level list. That is, when we speak, it is possible to say a few words, and each sentence may have different results. Like you said:

Oh, hello!

Have you eaten!

Among them, "Hello ah" identified as an alternative may have "Hello ah", "hello", "Hello" and so on.

"Have you eaten?" identified as an alternative may have "eat", "Eat No", "Eat ah" and so on.

So, the first-dimensional list of the function arguments is different, and the second dimension is the different recognition of each sentence . Do you understand? Do you understand?

We only recognize the first sentence in the example, let the screen pop up a dialog box to let us choose. Finally, let the button with Sogou Voice dialog binding, click the button pop-up speech recognition Service dialog.

3.3 Client Use

Direct:


Click "I want to talk!" ”:

Say "Hello" to the phone:

Choose your intention, backstage to get the text can do whatever you like! It's simple! More applications can refer to Sogou's sample program and SDK documentation.

Introduction to Sogou Voice Cloud development--easy to add voice recognition on the mobile side

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.