Speechly website | Docs | Blog
This repository contains the source code for the iOS client for Speechly SLU API. Speechly allows you to easily build applications with voice-enabled UIs.
The client is distributed using Swift Package Manager, so you can use it by adding it as a dependency to your Package.swift
:
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "MySpeechlyApp",
dependencies: [
.package(name: "speechly-ios-client", url: "https://github.com/speechly/ios-client.git", from: "0.1.0"),
],
targets: [
.target(
name: "MySpeechlyApp",
dependencies: []),
.testTarget(
name: "MySpeechlyAppTests",
dependencies: ["MySpeechlyApp"]),
]
)
And then running swift package resolve
.
If you are using Xcode, check out the official tutorial for adding package dependencies to your app.
The client exposes methods for starting and stopping the recognition, as well as a delegate protocol to implement for receiving recognition results:
import Foundation
import Speechly
class SpeechlyManager {
let client: SpeechClient
public init() {
self.client = try! SpeechClient(
// Specify your Speechly application's identifier here.
appId: UUID(uuidString: "your-speechly-app-id")!,
// Specify your Speechly application's language here.
language: .enUS
)
self.client.delegate = self
}
public func start() {
// Use this to unmute the microphone and start recognising user's voice input.
// You can call this when e.g. a button is pressed.
self.client.start()
}
public func stop() {
// Use this to mute the microphone and stop recognising user's voice input.
// You can call this when e.g. a button is depressed.
self.client.stop()
}
}
// Implement the `Speechly.SpeechClientDelegate` for reacting to recognition results.
extension SpeechlyManager: SpeechClientDelegate {
// (Optional) Use this method for telling the user that recognition has started.
func speechlyClientDidStart(_: SpeechClientProtocol) {
print("Speechly client has started an audio stream!")
}
// (Optional) Use this method for telling the user that recognition has finished.
func speechlyClientDidStop(_: SpeechClientProtocol) {
print("Speechly client has finished an audio stream!")
}
// Use this method for receiving recognition results.
func speechlyClientDidUpdateSegment(_ client: SpeechClientProtocol, segment: SpeechSegment) {
print("Received a new recognition result from Speechly!")
// What the user wants the app to do, (e.g. "book" a hotel).
print("Intent:", segment.intent)
// How the user wants the action to be taken, (e.g. "in New York", "for tomorrow").
print("Entities:", segment.entities)
// The text transcript of what the user has said.
// Use this to communicate to the user that your app understands them.
print("Transcripts:", segment.transcripts)
}
}
Check out the ios-repo-filtering repository for a demo app built using this client.
Check out official Speechly documentation for tutorials and guides on how to use this client.
You can also find the API documentation in the repo.
If you want to fix a bug or add new functionality, feel free to open an issue and start the discussion. Generally it's much better to have a discussion first, before submitting a PR, since it eliminates potential design problems further on.
- Swift 5.3+
- Xcode 12+
- Make
- swift-doc
Make sure you have Xcode and command-line tools installed. The rest of tools can be installed using e.g. Homebrew:
brew install swift make swiftdocorg/formulae/swift-doc
You can use various Make targets for building the project. Feel free to check out the Makefile, but most commonly used tasks are:
# Install dependencies, run tests, build release version and generate docs.
# Won't do anything if everything worked fine and nothing was changed in source code / package manifest.
make all
# Cleans the build directory, will cause `make all` to run stuff again.
make clean
Speechly is a developer tool for building real-time multimodal voice user interfaces. It enables developers and designers to enhance their current touch user interface with voice functionalities for better user experience. Speechly key features:
- Fully streaming API
- Multi modal from the ground up
- Easy to configure for any use case
- Fast to integrate to any touch screen application
- Supports natural corrections such as "Show me red – i mean blue t-shirts"
- Real time visual feedback encourages users to go on with their voice