This Dart package provides a client for the GhanaNLP API, including Automatic Speech Recognition (ASR) and Text-To-Speech (TTS) functionalities. It allows you to easily transcribe audio and synthesize speech in various Ghanaian and African languages. Get API KEY at
ghananlp.org
# GhanaNLP Dart Package
This Dart package provides a client for the GhanaNLP API, including Automatic Speech Recognition (ASR) and Text-To-Speech (TTS) functionalities. It allows you to easily transcribe audio and synthesize speech in various Ghanaian and African languages. Get API KEY at
ghananlp.org
## Supported Languages
- Twi (tw)
- Ga (gaa)
- Dagbani (dag)
- Ewe (ee)
- Kikuyu (ki)
## Installation
Add this package to your project's `pubspec.yaml` file:
```yaml
dependencies:
ghana_nlp_dart:
git:
url:
github.com
ref: main
```
Then run:
```
dart pub get
```
## Usage
Here are basic examples of how to use the GhanaNLP Dart package:
### Automatic Speech Recognition (ASR)
```dart
import 'dart:io';
import 'package:ghana_nlp_dart/ghana_nlp_dart.dart';
void main() async {
final apiKey = 'your_api_key_here';
final ghanaNlpAsr = GhanaNlpAsr(apiKey: apiKey);
// Read audio file
final file = File('path_to_your_audio_file.mp3');
final audioBytes = await file.readAsBytes();
try {
final transcription = await ghanaNlpAsr.transcribe(audioBytes, Language.twi.code);
print('Transcription: $transcription');
} catch (e) {
print('Error: $e');
}
}
```
### Text-To-Speech (TTS)
```dart
import 'dart:io';
import 'package:ghana_nlp_dart/ghana_nlp_dart.dart';
void main() async {
final apiKey = 'your_api_key_here';
final ghanaNlpTts = GhanaNlpTts(apiKey: apiKey);
try {
final audioBytes = await ghanaNlpTts.synthesize('Ɛte sɛn?', Language.twi.code);
await File('output.mp3').writeAsBytes(audioBytes);
print('Audio saved to output.mp3');
} catch (e) {
print('Error: $e');
}
}
```
### Text-To-Speech (TTS)
```dart
import 'package:ghana_nlp_dart/ghana_nlp_dart.dart';
void main() async {
final api = GhanaNLPTranslationAPI(apiKey: 'your_api_key_here');
// Translate text
try {
final translatedText = await api.translate(
text: 'Hello, how are you?',
languagePair: 'en-tw',
);
print('Translated text: $translatedText');
} catch (e) {
print('Tra …