Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakubpetrik/animalese-swift
Swift library that synthesizes an approximation of the villager speech sounds from Animal Crossing. Port of https://github.com/Acedio/animalese.js
https://github.com/jakubpetrik/animalese-swift
animal-crossing swift text-to-speech
Last synced: about 2 months ago
JSON representation
Swift library that synthesizes an approximation of the villager speech sounds from Animal Crossing. Port of https://github.com/Acedio/animalese.js
- Host: GitHub
- URL: https://github.com/jakubpetrik/animalese-swift
- Owner: jakubpetrik
- Created: 2020-04-14T04:58:46.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-14T08:23:55.000Z (over 4 years ago)
- Last Synced: 2024-10-13T14:46:43.042Z (3 months ago)
- Topics: animal-crossing, swift, text-to-speech
- Language: Swift
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Animalese-Swift
[![platform](https://img.shields.io/badge/platform-macOS%20|%20iOS%20|%20watchOS%20|%20tvOS-blue.svg)]()
[![SwiftPM-compatible](https://img.shields.io/badge/SwiftPM-✔-4BC51D.svg?style=flat)](https://swift.org/package-manager/)A Swift port of https://github.com/Acedio/animalese.js.
### Usage
```swift
import SwiftUI
import AVFoundation
import Animalese_Swiftstruct ContentView: View {
@State var text = "Well, I do have a little musical knowledge..."
@State var pitch = 1.0
@State var shortenWords = false
@State var player: AVAudioPlayer!private let synth = Animalese(
letterLibrary: NSDataAsset(name: "animalese")!.data,
sampleRate: 44100,
libraryLetterSeconds: 0.15,
outputLetterSeconds: 0.075
)var body: some View {
NavigationView {
Form {
TextField("Type here...", text: $text)
Slider(value: $pitch, in: 0.2...2.0, step: 0.1, minimumValueLabel: Text("😡"), maximumValueLabel: Text("🐹")) {
Text("Pitch")
}
Toggle(isOn: $shortenWords) {
Text("Words shortening")
}
Button(action: play) {
Text("Play")
}
}.navigationBarTitle(Text("Animalese-Swift Demo"))
}
}func play() {
let data = synth.synthesize(text, shortenWords: shortenWords, pitch: pitch)
player = try! AVAudioPlayer(data: data)
player.play()
}
}```
## Installation
### Swift Package Manager
Animalese-Swift is SwiftPM-compatible. To install, add this package to your `Package.swift` or your Xcode project.