npm package: @neooosky/z-tool
Description: A tool to translate MDX/MD files using OpenAI API
Latest version: 1.0.13

## Prerequisites

The tool requires several external dependencies for full functionality. Here's how to install them on different platforms:

### macOS

Using Homebrew:

```bash
# Install Homebrew if you haven't
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install dependencies
brew update
brew install ffmpeg        # Required for audio/video operations
brew install pandoc       # Required for document conversion
brew install poppler     # Required for PDF operations
brew install --cask calibre # Required for MOBI to txt conversions
```

### Ubuntu/Debian

```bash
sudo apt-get update
sudo apt-get install -y \
  ffmpeg \              # Required for audio/video operations
  pandoc \             # Required for document conversion
  poppler-utils \        # Required for PDF operations
  calibre            # Required for MOBI to txt conversions
```

### Python Dependencies

我们推荐使用 Miniconda 来管理 Python 环境：

1. 首先安装 Miniconda：

```bash
# 下载Miniconda安装脚本
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOS-x86_64.sh

# 运行安装脚本
bash Miniconda3-latest-MacOS-x86_64.sh
```

2. 创建并激活虚拟环境：

```bash
# 创建名为spleeter-env的虚拟环境
conda create -n spleeter-env python=3.8

# 激活虚拟环境
conda activate spleeter-env
```

3. 安装 Python 依赖：

人声分离：

```bash
conda install -c conda-forge ffmpeg libsndfile
conda create -n spleeter-env python=3.8
conda activate spleeter-env
pip install spleeter
```

### NPM Dependencies

```bash
npm install xlsx        # Required for Excel file operations
npm install sharp       # Required for image format conversion (auto-installed)
```

## Commands

### convert

Convert files between different formats.

```bash
z-tool convert [options]

Options:
  -f, --file <file>       Specific file to convert
  -o, --origin <format>   Origin file format
  -t, --target <format>   Target file format (default: "mp3")
  -q, --quality <quality> Image quality for compression (1-100, default: 80)
  -r, --recursive         Process files recursively in subdirectories
```

Supported conversions:

- **Media**: mp4/avi/mov → mp3/wav
- **Images** (jpg, jpeg, png, webp, gif):
  - Convert between any supported image formats
  - Omit `-o` to convert ALL image formats to target
  - Supports quality control and recursive processing
- **Documents**:
  - doc/docx → txt
  - pdf → txt
  - mobi → txt
  - xls/xlsx → csv
  - md ⇄ docx (bidirectional)

Examples:

```bash
# Media
z-tool convert -f video.mp4            # Convert video.mp4 to video.mp3
z-tool convert -o mp4 -t wav           # Convert all mp4 to wav

# Images
z-tool convert -t webp                 # Convert ALL images to WebP
z-tool convert -t webp -r              # Recursively convert ALL images to WebP
z-tool convert -t webp -q 90           # Convert with 90% quality
z-tool convert -o png -t webp          # Convert only PNG to WebP
z-tool convert -f image.png -t jpg     # Convert single image

# Documents
z-tool convert -o docx -t txt          # Convert all docx files to txt
z-tool convert -f document.pdf -t txt  # Convert PDF to text
z-tool convert -f ebook.mobi -t txt    # Convert MOBI ebook to text
z-tool convert -f data.xlsx -t csv     # Convert Excel to CSV
z-tool convert -f doc.md -t docx       # Convert Markdown to Word
z-tool convert -f doc.docx -t md       # Convert Word to Markdown
```

### concat

Concatenate multiple audio or video files.

```bash
z-tool concat <files...> [options]

Options:
  -o, --output <filename>  Output filename
```

Supported file types:

- Audio: mp3, wav
- Video: mp4, avi, mov

Examples:

```bash
z-tool concat part1.mp3 part2.mp3 -o full.mp3
z-tool concat "intro.mp4" "main.mp4" "outro.mp4" -o final.mp4
z-tool concat *.mp3 -o combined.mp3
```

### compress

Compress files.

```bash
z-tool compress [options]

Options:
  -f, --file <file>  File to compress
```

### translator

Translate text between languages.

```bash
z-tool translator [options]

Options:
  [options details...]
```

### tts (Text-to-Speech)

Convert text to speech.

```bash
z-tool tts [options]

Options:
  [options details...]
```

## Troubleshooting

### Common Issues

1. **Command not found**

   - Ensure the package is installed globally
   - Check if npm global binaries are in your PATH

2. **Conversion fails**

   - Verify all required dependencies are installed
   - Check if input files exist and are not corrupted
   - Ensure you have write permissions in the output directory

3. **FFmpeg errors**
   - Make sure FFmpeg is properly installed
   - For video/audio operations, check if the input files are valid media files

### Checking Dependencies

You can verify if dependencies are properly installed:

```bash
# Check FFmpeg
ffmpeg -version

# Check Pandoc
pandoc --version

# Check Poppler tools
pdftotext -v
```

## License

[License details]

## Contributing

[Contributing guidelines]

```

```