zifty 0.0.1
zifty: ^0.0.1 copied to clipboard
Voice Pilot
Zifty #
A specialized Flutter Package for providing real-time voice communication and command processing capabilities.
Features #
- 🎤 Real-time voice communication
- 🗣️ Voice command processing
- 🔇 Audio stream mute/unmute capabilities
- 📱 Flexible UI layouts for different form factors
Platform Support #
Flutter Pilot supports all major platforms:
- ✓ Android
- ✓ iOS
- ✓ Web
- ✓ Windows
- ✓ macOS
- ✓ Linux
Getting Started #
- Add
flutter_pilotas a dependency in yourpubspec.yaml:
dependencies:
flutter_pilot: ^0.0.1
- Run:
flutter pub get
Usage #
Basic Implementation #
- Obtain an ephemeral key:
// Using API
Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: AudioChatWidget(
showMuteButton: true,
horizontalLayout: true,
initialContext: "User Name is John.",
headers: const {'Content-Type': 'application/json'},
credentialsUrl: "Url to get authToken and apiKey",
getCredentials: _getCredentials, //Either this future method or credentialsUrl way
onError: (e) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Error connecting to audio chat: $e")));
},
userToken: "loggedIn user token(for api calling)[Optional]"
),
),
);
- Getting Credentials Via API:
Future<Map<String, String>> _getCredentials() async {
try {
final response = await http.post(
Uri.parse("Url to get authToken and apiKey"),
headers: {'Content-Type': 'application/json'},
);
if (response.statusCode == 200) {
var apiResponse = json.decode(response.body);
print(apiResponse);
return {"apiKey": apiResponse["ephemeralKey"], "authToken": apiResponse["token"]};
} else {
print(
'Failed to send function call data to API. Status code: ${response.statusCode}');
}
} catch (e) {
print('Error sending function call data to API: $e');
}
return {};
}
API Documentation #
AudioChatWidget #
The main widget for starting.
Properties
apiKey: This is Ephemeral Key for connectionauthToken: Client authentication tokenuserToken: Optional logged-in user tokeninitialContext: Optional initial conversation contextonError: Callback for errorshorizontalLayout: Widget layout orientationgetCredentials: Future API for getting credentialscredentialsUrl: Credential URl(Either this or getCredentails is required)headers: used if {credentialsUrl} is provided.body: used if {credentialsUrl} is provided.
License #
This project is licensed under the MIT License - see the LICENSE file for details.