Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Lint and Format Check

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.10'

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Install dependencies
run: |
uv sync --dev --frozen

- name: Run linting and formatting checks
run: |
make format-and-lint

- name: Check for uncommitted changes
run: |
if [[ -n $(git diff --exit-code) ]]; then
echo "::error::Linting and formatting checks failed. Please run 'make format-and-lint' locally and commit the changes."
git diff
exit 1
fi
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ format-and-lint:
uv run --no-sync --project . ruff format
uv run --no-sync --project . ruff check --fix

bump-patch:
uv version --bump patch
uv sync
@echo "Patch version bumped and recreated lock file."

bump-minor:
uv version --bump minor
uv sync
@echo "Minor version bumped and recreated lock file."

publish-test:
uv build
@if [ -z "$(PYPI_TEST_TOKEN)" ]; then echo "Error: TEST_PYPI_TOKEN is not set"; exit 1; fi
Expand Down
14 changes: 7 additions & 7 deletions hns/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import sounddevice as sd
from faster_whisper import WhisperModel
from rich.console import Console
from rich.live import Live
from rich.progress import Progress, SpinnerColumn, TextColumn, TimeElapsedColumn
from rich.text import Text

console = Console()

Expand All @@ -25,7 +23,7 @@ def format_duration(seconds: float) -> str:
hours = total_seconds // 3600
minutes = (total_seconds % 3600) // 60
secs = total_seconds % 60

if hours > 0:
return f"{hours}:{minutes:02d}:{secs:02d}"
else:
Expand Down Expand Up @@ -64,16 +62,18 @@ def record(self) -> Path:
start_time = time.time()
recording_stopped = threading.Event()


try:
with stream:

def update_timer():
"""Update the display with elapsed time."""
while not recording_stopped.is_set():
elapsed = time.time() - start_time
time_str = format_duration(elapsed)
# Overwrite the same line
console.print(f"🎤 [bold blue]Recording {time_str}... Press Enter to stop[/bold blue]", end="\r")
console.print(
f"🎤 [bold blue]Recording {time_str}... Press Enter to stop[/bold blue]", end="\r"
)
time.sleep(1)

# Start timer thread
Expand All @@ -83,11 +83,11 @@ def update_timer():

# Wait for user input
input()

# Stop timer and wait for thread to finish
recording_stopped.set()
timer_thread.join(timeout=2) # Wait up to 2 seconds for thread to finish

# Clear the recording line completely
console.print(" " * 50, end="\r") # Clear line with spaces

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "hns"
version = "1.0.3"
version = "1.0.4"
description = "A simple, privacy-focused speech-to-text CLI tool"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.