Sogou speech cloud development portal-easily add speech recognition on the Mobile End and cloud Development Speech Recognition

Source: Internet
Author: User

Sogou speech cloud development portal-easily add speech recognition on the Mobile End and cloud Development Speech Recognition
1 Overview

Based on self-developed and industry-leading voice technology, sogou voice cloud strives to provide developers with the best voice service. Developers only need to integrate voice cloud controls in a simple manner, you can call the sogou voice cloud service through APIS to obtain powerful voice technical support from sogou and focus more on business development.

2. Services provided

  • Online speech recognition technology:

Official Note: This technology allows computers to "understand" human speech and convert voice signals into texts through machines.

To put it bluntly, the online voice resolution is text.

  • Offline speech recognition technology:

Official Language: This technology uses a local offline voice package to directly convert voice input recognition to text, replacing cloud server features.

To put it bluntly, it means offline speech resolution is text and there is no need to connect to the Internet.

  • Online Music recognition technology:

Official Note: Based on sogou's own technology, this technology provides free and efficient music listening service to small and medium-sized developers. You don't have to pay too much for the title. You only need to record and submit music clips, and sogou music cloud automatically gives the artist and song name.

To put it bluntly, Jay Chou's song is hard to find.

  • Offline speech synthesis technology:

Official Language: This technology enables computers to convert external text information into natural and fluent spoken Chinese, so that computers have the same ability to speak as humans, offline speech synthesis can synthesize high-quality speech on the device without relying on the network.

To put it bluntly, text is converted to speech.

3. How to Use

The voice service is mysterious and difficult to understand. Now, we only need to make simple calls and do not make any calls. From then on, My mother no longer has to worry about my learning. so easy!

3.1 Procedure

The procedure is not difficult.

First, you must register a sogou voice cloud account.

Next, select the service to be applied for in "application information" on the left after logging in:

You can also perform "quick experience ". If you have never used sogou voice cloud service, we recommend that you enter the quick experience area for a quick experience. The advantage is that you can quickly obtain appId to call the service without sogou review, the disadvantage is that the number of services is limited, but 500 times a day is generally enough:

Click "My applications" in the upper right corner to view the appId applied for quickly:

Record id information, which must be used in the service!

3.2 call services

Here we will talk about how to call it on the client. We will use the "quick experience" application to use "Speech Recognition" on the "Android" platform as an example.

Let's take a look at what sogou gave us apart from appId...

The first is the called SDK package, and the second is the call description.

Put the files in the libs folder in the SDK package:

Put a brain in the libs of your Android project, and introduce the sogou-srop.jar into Build Path in the project.

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/plugin" android: paddingRight = "@ dimen/android" 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 speak! "/> </RelativeLayout> </span>

Call code in 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. menu. 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 AndroidManifest.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 attributes () {}@ 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); dialog = new RecognizerDialog (getActivity (), "appId", "accessKey", true, false); dialog. setlistener (new RecognizerListener () {@ Overridepublic void onResults (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 ("what you mean :"). 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 <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>

See? We first defined a dialog, which is the voice dialog box of the referenced sogou voice. Then, set a listener for dialog: RecognizerListener to monitor users' voice behavior. Note: Replace "appId" and "accessKey" with the value obtained after the application. Of course, some callback functions must be implemented here.

In the onResults function, we can define the behavior after obtaining the voice result. Let's take a look at the onResults function:

<span style="font-size:18px;">public void onResults(List<List<String>> arg0)</span>

We can see that its function is a list of two layers. That is to say, when we speak, we may say several sentences, and each sentence may have different results. For example, you said:

Hello!

Have you eaten!

Among them, the Standby options identified by "hello" may include "hello", "hello", and "hello.

The standby options identified by "Have you eaten?", and "have you eaten.

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

In this example, we only recognize the first sentence. Let's select a dialog box that appears on the screen. Finally, bind the button to sogou speech's dialog, and click the button to bring up the speech recognition service dialog.

3.3 client usage

Direct:


Click "I want to speak !" :

Say "hello" to your phone ":

If you select your intention, you can get the text in the background to do whatever you want! Easy! For more applications, refer to sogou's sample program and SDK documentation.

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.