/go-novel-reader

📚🎧 __go-novel-reader: 你的私人命令行小说朗读神器!__ 厌倦了盯着屏幕看小说?让 `go-novel-reader` 用纯正的 macOS 语音为你“讲故事”吧!它能智能分割章节、记住阅读进度,支持多书库管理,让你随时随地解放双眼,沉浸在小说的世界。

Primary LanguageGo

📚 go-novel-reader: Your Personal Command-Line Novel Narrator!

Go Report Card Go Version

English | 中文

Tired of staring at the screen to read novels? Let go-novel-reader read them aloud for you!

This is a command-line tool written in Go that reads your locally stored novel files (TXT or Markdown format). It automatically identifies and splits chapters, utilizes macOS's built-in TTS (Text-to-Speech) to "tell the story," and remembers your reading progress for each novel, down to the paragraph!

✨ Features

  • Multi-Novel Library: Easily add, list, remove, and switch between your novel collection (add, list, remove, switch).
  • Smart Chapter Splitting: Automatically detects common chapter title formats (Chinese numerals, English "Chapter X", Markdown headers) and splits accordingly.
  • Smooth TTS Reading: Calls macOS's say command to read selected chapters segment by segment (read, next, prev).
  • Precise Progress Saving: Saves the last read chapter and segment index individually for each novel. Pick up right where you left off!
  • Auto-Continue: Optional configuration to automatically start the next segment/chapter after finishing the current one (config auto_next).
  • Convenient Navigation: Quickly check your current reading position and the chapter list (where, chapters).
  • Cross-Platform? (macOS Only): Currently relies on the macOS say command, so it only supports macOS.

🖥️ Requirements

  • macOS: Required, due to dependency on the say command for TTS.
  • Go: Go compilation environment (e.g., Go 1.24 or later) needed for building.

🚀 Installation

Option 1: Using go install (Recommended)

If your Go environment is set up correctly (GOPATH, GOBIN in PATH), you can run:

go install github.com/xqbumu/go-novel-reader@latest

This will download, compile, and install the go-novel-reader executable into your $GOPATH/bin (or $GOBIN) directory.

Option 2: Manual Build

  1. Clone the repository:
    git clone https://github.com/xqbumu/go-novel-reader.git
    cd go-novel-reader
  2. Build:
    go build
    This generates an executable named go-novel-reader in the current directory. You can move this file to any location in your system's PATH for global access.

💡 Usage

# Add a new novel to the library and set it as active
./go-novel-reader add /path/to/your/novel.txt

# List all novels in the library and their progress
./go-novel-reader list

# Switch to the second novel in the library
./go-novel-reader switch 2

# List all chapters of the active novel
./go-novel-reader chapters

# Continue reading the active novel from where you left off
./go-novel-reader read

# Start reading the active novel from Chapter 5
./go-novel-reader read 5

# Read the next chapter of the active novel
./go-novel-reader next

# Read the previous chapter of the active novel
./go-novel-reader prev

# Show the active novel and current reading progress
./go-novel-reader where

# View or toggle configuration settings (e.g., auto-continue)
./go-novel-reader config          # View current config
./go-novel-reader config auto_next # Toggle the state of auto_next (true/false)

# Get help information
./go-novel-reader --help

⚙️ Configuration Files

go-novel-reader creates files in your user configuration directory to store information:

  • ~/.config/go-novel-reader/config.json: Stores the library list, active novel path, and application settings (like auto_next).
  • ~/.config/go-novel-reader/progress.json: Stores the reading progress for each novel (last read chapter and segment index).

You typically don't need to edit these files manually.

🔮 Future Ideas

  • Support for more TTS engines?
  • Cross-platform support? (Requires finding alternatives to say)
  • More configuration options?

Suggestions and contributions are welcome!