The package is intended for STT, LLM and TSS models chaining.
Project description
cockatoo_chain
This repo is intended for STT, LLM and TSS models chaining.
Development Mode
Development Mode is intended for users who wish to contribute to the repo and thus needs to install additional dev-related packages for, e.g., code quality checking, to satisfy the standard of the repo. If you hope to contribute to the repository, please follow up the follow instructions:
Create virtual environment by poetry
# Force poetry to build virtual environment in the repo.
$ poetry config virtualenvs.in-project true
# Create virtual environment
$ poetry env use python
# Confirm the created virtual environment
$ poetry env info
Enter virtual environment and installed packages
# Get the command to enter virtual environment
$ poetry env activate
$ source activate <your venv>
$ make init-repo-setup
Model A Usage
From cockagoo_chain package, you can easily access the power of Model A (Speech-to-text) with a few lines of codes. We will learn how to from this section. For the time being, cockagoo_chain support below types of model A:
| Name | Type | Supported language | Supported file type | Note |
|---|---|---|---|---|
| open_ai_whisper | Remote API | en, cn and more | File uploads are currently limited to 25 MB, and the following input file types are supported: mp3, mp4, mpeg, mpga, m4a, wav, and webm | Official doc |
| gcp_stt | Remote API | en, cn and more | For details, please refer to this link | Official doc |
Get supported Model A options
You can use below code snippet to get the supported model A options:
>>> from cockatoo_chain.utils import model_a
>>> model_type = model_a.ModelType
>>> list(model_type)
[<ModelType.OPEN_AI_WHISPER: 'open_ai_whisper'>]
Transform input audio file into text
Below code snippet demonstrates how to obtain the OpenAI whipser wrapper for model A and apply it to transform the audio file into text:
>>> test_en_audio_file_path = '~/test_audio_files/en_20240108_johnlee.wav'
>>> model_a_wrapper = model_a.get(model_type.OPEN_AI_WHISPER)
>>> response = model_a_wrapper.audio_2_text(test_en_audio_file_path)
>>> response
Audio2TextData(
text='Hello, this is for testing in English. We will use this to evaluate model SST...',
spent_time_sec=7.87896990776062,
audio_file_path='/root/test_audio_files/en_20240108_johnlee.wav')
>>> response.text
'Hello, this is for testing in English. We will use this to evaluate model SST and see how it performs. Thanks.'
Model C Usage
From cockagoo_chain package, you can easily access the power of Model C (Text-to-speech) with a few lines of codes. We will learn how to from this section. For the time being, cockagoo_chain support below types of model C:
| Name | Type | Supported language | Supported output file type | Note |
|---|---|---|---|---|
| gcp_text_2_speech | Remove API | en, cn and more | wav | Offical doc |
Get supported Model C options
>>> from cockatoo_chain.utils import model_c
>>> mt = model_c.ModelType
>>> list(mt)
[<ModelType.GCP_TEXT_2_SPEECH: 'gcp_text_2_speech'>]
Transform text into speech
Below code snippet demonstrates how to obtain the GCP text-to-speech wrapper as model C and apply it to transform give text into speech and save it as audio file:
>>> mc_imp = model_c.get(mt.GCP_TEXT_2_SPEECH)
>>> mc_imp.name
'GCP/text-to-speech'
>>> mc_imp.text_2_audio("Nice to meet you all and welcome to join Cockatoo-AI's group meeting!")
Text2AudioData(
text="Nice to meet you all and welcome to join Cockatoo-AI's group meeting!",
spent_time_sec=1.822951,
generated_audio_file_path='/tmp/gcp_tts_output.wav')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cockatoo_chain-0.1.1.tar.gz.
File metadata
- Download URL: cockatoo_chain-0.1.1.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.3 Linux/6.11.0-24-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c350bdf4251ea722c294dcb47ee66a176522327d227d92c9e7219a7e78977332
|
|
| MD5 |
338a43fcf6d11ce8e651b1c15a7d8ed1
|
|
| BLAKE2b-256 |
31f64bf5b4718ea15011a6231fd6549da028e58c195aa16f6d31b9d323ca52f8
|
File details
Details for the file cockatoo_chain-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cockatoo_chain-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.3 Linux/6.11.0-24-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29065ba60bb5d27120d7c0dc0324c01bedbfd957f515e7b93b726e5e739be300
|
|
| MD5 |
3f7f505a7f5efce1b72fcaa20cd80c99
|
|
| BLAKE2b-256 |
a10025b8552fca1cb3013f35f4568c68cdf1400b1c99dcb348aa69c32031d529
|