Giter VIP home page Giter VIP logo

googlestt's Introduction

Cloud Speech Streaming gRPC Swift Sample

This app demonstrates how to make streaming gRPC connections to the Cloud Speech API to recognize speech in recorded audio.

Prerequisites

Quickstart

  • Clone this repo and cd into this directory.
  • Run ./INSTALL
  • In Speech/SpeechRecognitionService.swift, replace YOUR_API_KEY with the API key obtained above.
  • Build and run the app.

Running the app

  • As with all Google Cloud APIs, every call to the Speech API must be associated with a project within the Google Cloud Console that has the Speech API enabled. This is described in more detail in the getting started doc, but in brief:

  • Clone this repository on GitHub. If you have git installed, you can do this by executing the following command:

      $ git clone https://github.com/GoogleCloudPlatform/ios-docs-samples.git
    

    This will download the repository of samples into the directory ios-docs-samples.

  • cd into this directory in the repository you just cloned, and run the command pod install to prepare all Cocoapods-related dependencies.

  • open Speech.xcworkspace to open this project in Xcode. Since we are using Cocoapods, be sure to open the workspace and not Speech.xcodeproj.

  • In Xcode's Project Navigator, open the SpeechRecognitionService.swift file within the Speech directory.

  • Find the line where the API_KEY is set. Replace the string value with the API key obtained from the Cloud console above. This key is the credential used to authenticate all requests to the Speech API. Calls to the API are thus associated with the project you created above, for access and billing purposes.

  • You are now ready to build and run the project. In Xcode you can do this by clicking the 'Play' button in the top left. This will launch the app on the simulator or on the device you've selected. Be sure that the 'Speech' target is selected in the popup near the top left of the Xcode window.

  • Tap the Start Streaming button. This uses a custom AudioController class to capture audio in an in-memory instance of NSMutableData. When this data reaches a certain size, it is sent to the SpeechRecognitionService class, which streams it to the speech recognition service. Packets are streamed as instances of the RecognizeRequest object, and the first RecognizeRequest object sent also includes configuration information in an instance of InitialRecognizeRequest. As it runs, the AudioController logs the number of samples and average sample magnitude for each packet that it captures.

  • Say a few words and wait for the display to update when your speech is recognized.

  • Tap the Stop Streaming button to stop capturing audio and close your gRPC connection.

googlestt's People

Contributors

zhengshunze avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.