edge-tts icon indicating copy to clipboard operation
edge-tts copied to clipboard

Add GitHub Actions workflow for PyPI publishing and new saveMore method

Open labKnowledge opened this issue 4 months ago • 0 comments

Summary

This PR introduces two main enhancements to the edge-tts project:

1. GitHub Actions Workflow for PyPI Publishing

  • File: .github/workflows/python-publish.yml
  • Purpose: Automates the publishing of Python packages to PyPI when a release is created
  • Features:
    • Triggers on release publication
    • Uses Python 3.x with latest pip
    • Builds package using python -m build
    • Publishes to PyPI using pypa/gh-action-pypi-publish
    • Uses secure token-based authentication via PYPI_API_TOKEN secret

2. New saveMore Method in Communicate Class

  • File: src/edge_tts/communicate.py
  • Method: saveMore(audio_fname, metadata_fname=None)
  • Purpose: Enhanced audio and metadata saving with support for various file types
  • Features:
    • Supports multiple file input types: strings, bytes, BytesIO, BinaryIO
    • Flexible metadata handling with optional metadata file
    • Proper file object management with context managers
    • Maintains compatibility with existing streaming functionality
    • Handles both file paths and file-like objects seamlessly

Technical Details

GitHub Actions Workflow

The workflow is configured to:

  • Run on Ubuntu latest
  • Checkout the repository
  • Set up Python environment
  • Install build dependencies
  • Build the package
  • Publish to PyPI using secure token authentication

saveMore Method Implementation

The new method provides:

  • Type-safe file handling for different input types
  • Proper resource management with context managers
  • Backward compatibility with existing code
  • Enhanced flexibility for various use cases

Benefits

  1. Automated Publishing: Reduces manual work for package releases
  2. Enhanced API: More flexible file handling for audio and metadata
  3. Better Developer Experience: Simplified workflow for package management
  4. Security: Uses secure token-based authentication for PyPI

Testing

  • The workflow has been tested for proper configuration
  • The saveMore method maintains compatibility with existing functionality
  • All changes are backward compatible

Files Changed

  • .github/workflows/python-publish.yml (new file)
  • src/edge_tts/communicate.py (enhanced with new method)

labKnowledge avatar Oct 10 '25 00:10 labKnowledge