-
Notifications
You must be signed in to change notification settings - Fork 25
feat: replace mypy with ty #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
67a26df
chore(deps): add ty package version 0.0.2 to dependencies
twangodev a7635c9
chore: update type hints and add typing-extensions dependency
twangodev eb7abc9
chore: remove mypy dependency and update CI to use ty for type checking
twangodev 5240b45
refactor: update type hints to use Iterable instead of Iterator for a…
twangodev 4fbcb78
feat: add example ipynb
twangodev bf1658e
fix: lint with import clarification
twangodev b0e094b
fix: clear ipynb
twangodev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "# Fish Audio SDK - Getting Started\n", | ||
| "\n", | ||
| "This notebook demonstrates the basic usage of the Fish Audio Python SDK:\n", | ||
| "- Initialize the client\n", | ||
| "- Convert text to speech\n", | ||
| "- Save and play audio\n", | ||
| "- Use different voices" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Setup\n", | ||
| "\n", | ||
| "First, install the SDK and set your API key:\n", | ||
| "\n", | ||
| "```bash\n", | ||
| "pip install fishaudio\n", | ||
| "export FISH_API_KEY=\"your_api_key\"\n", | ||
| "```\n", | ||
| "\n", | ||
| "Or create a `.env` file with `FISH_API_KEY=your_api_key`" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "ExecuteTime": { | ||
| "end_time": "2025-12-17T02:19:01.713412Z", | ||
| "start_time": "2025-12-17T02:19:01.692232Z" | ||
| } | ||
| }, | ||
| "outputs": [], | ||
| "source": "from dotenv import load_dotenv\nfrom fishaudio import FishAudio\nfrom fishaudio.utils import play\n# from fishaudio.utils import save # Uncomment if saving audio to file\n\nload_dotenv()\n\nclient = FishAudio()" | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Simple Text-to-Speech\n", | ||
| "\n", | ||
| "Convert text to speech and play it directly in the notebook." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "ExecuteTime": { | ||
| "end_time": "2025-12-17T02:19:02.811072Z", | ||
| "start_time": "2025-12-17T02:19:01.715025Z" | ||
| } | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "audio = client.tts.convert(text=\"Hello! Welcome to Fish Audio.\")\n", | ||
| "\n", | ||
| "play(audio, notebook=True)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Save Audio to File\n", | ||
| "\n", | ||
| "Save the generated audio to an MP3 file." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "ExecuteTime": { | ||
| "end_time": "2025-12-17T02:19:02.822441Z", | ||
| "start_time": "2025-12-17T02:19:02.818578Z" | ||
| } | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# audio = client.tts.convert(text=\"This audio will be saved to a file.\")\n", | ||
| "# save(audio, \"output.mp3\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Using a Specific Voice\n", | ||
| "\n", | ||
| "Use `reference_id` to specify a voice model from your Fish Audio account." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "ExecuteTime": { | ||
| "end_time": "2025-12-17T02:19:02.826568Z", | ||
| "start_time": "2025-12-17T02:19:02.822894Z" | ||
| } | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# Replace with your voice model ID\n", | ||
| "# audio = client.tts.convert(\n", | ||
| "# text=\"Hello from a custom voice!\",\n", | ||
| "# reference_id=\"your-voice-model-id\"\n", | ||
| "# )\n", | ||
| "# play(audio, notebook=True)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Streaming Audio\n", | ||
| "\n", | ||
| "For longer text, use `stream()` to process audio chunks as they arrive." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "ExecuteTime": { | ||
| "end_time": "2025-12-17T02:19:03.824681Z", | ||
| "start_time": "2025-12-17T02:19:02.826991Z" | ||
| } | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "stream = client.tts.stream(text=\"This is a longer piece of text that will be streamed.\")\n", | ||
| "audio = stream.collect()\n", | ||
| "\n", | ||
| "play(audio, notebook=True)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## Check Account Credits" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "ExecuteTime": { | ||
| "end_time": "2025-12-17T02:19:03.897563Z", | ||
| "start_time": "2025-12-17T02:19:03.833734Z" | ||
| } | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "credits = client.account.get_credits()\n", | ||
| "print(f\"Remaining credits: {credits.credit}\")" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "Python 3", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "name": "python", | ||
| "version": "3.11.0" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 4 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.