Skip to content

Commit

Permalink
refactor: rename speech-box to vox-box
Browse files Browse the repository at this point in the history
  • Loading branch information
aiwantaozi committed Nov 22, 2024
1 parent aebe8bc commit ed7bdda
Show file tree
Hide file tree
Showing 45 changed files with 130 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ exclude =
.venv,
.pytest_cache,
.mypy_cache
speech_box/third_party
vox_box/third_party
28 changes: 14 additions & 14 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
source "${ROOT_DIR}/hack/lib/init.sh"

function build() {
if speech_box::util::is_darwin; then
if vox_box::util::is_darwin; then
build_platform "macosx_11_0_universal2"
elif speech_box::util::is_linux; then
elif vox_box::util::is_linux; then
# This is a temporary workaround to make the wheel files different.
echo >> "${ROOT_DIR}/README.md"
build_platform "manylinux2014_x86_64"
echo >> "${ROOT_DIR}/README.md"
build_platform "manylinux2014_aarch64"
# Remove the extra newline.
# shellcheck disable=SC2016
speech_box::util::sed '${/^$/d;}' "${ROOT_DIR}/README.md"
vox_box::util::sed '${/^$/d;}' "${ROOT_DIR}/README.md"
fi
}


function build_platform() {
platform="${1:-}"
if [ -z "$platform" ]; then
speech_box::log::fatal "undefined platform to build"
vox_box::log::fatal "undefined platform to build"
fi

poetry build

dist_dir="$ROOT_DIR/dist"
whl_files=$(find "$dist_dir" -name "*.whl")
if [ -z "$whl_files" ]; then
speech_box::log::fatal "no wheel files found in $dist_dir"
vox_box::log::fatal "no wheel files found in $dist_dir"
fi

for whl_file in $whl_files; do
if [[ "$whl_file" == *-any* ]]; then
original_name=$(basename "$whl_file")
new_name="${original_name/any/$platform}"
mv -f "$whl_file" "$dist_dir/$new_name"
speech_box::log::info "renamed $original_name to $new_name"
vox_box::log::info "renamed $original_name to $new_name"
fi
done
}
Expand All @@ -52,33 +52,33 @@ function prepare_dependencies() {
}

function set_version() {
local version_file="${ROOT_DIR}/speech_box/__init__.py"
local version_file="${ROOT_DIR}/vox_box/__init__.py"
local git_commit="${GIT_COMMIT:-HEAD}"
local git_commit_short="${git_commit:0:7}"

speech_box::log::info "setting version to $GIT_VERSION"
speech_box::log::info "setting git commit to $git_commit_short"
vox_box::log::info "setting version to $GIT_VERSION"
vox_box::log::info "setting git commit to $git_commit_short"

# Replace the __version__ variable in the __init__.py file
speech_box::util::sed "s/__version__ = .*/__version__ = '${GIT_VERSION}'/" "${version_file}"
speech_box::util::sed "s/__git_commit__ = .*/__git_commit__ = '${git_commit_short}'/" "${version_file}"
vox_box::util::sed "s/__version__ = .*/__version__ = '${GIT_VERSION}'/" "${version_file}"
vox_box::util::sed "s/__git_commit__ = .*/__git_commit__ = '${git_commit_short}'/" "${version_file}"

# Update the poetry version
poetry version "${GIT_VERSION}"
}

function restore_version_file() {
local version_file="${ROOT_DIR}/speech_box/__init__.py"
local version_file="${ROOT_DIR}/vox_box/__init__.py"
git checkout -- "${version_file}"
}

#
# main
#

speech_box::log::info "+++ BUILD +++"
vox_box::log::info "+++ BUILD +++"
prepare_dependencies
set_version
build
restore_version_file
speech_box::log::info "--- BUILD ---"
vox_box::log::info "--- BUILD ---"
4 changes: 2 additions & 2 deletions hack/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ function ci() {
# main
#

speech_box::log::info "+++ CI +++"
vox_box::log::info "+++ CI +++"
ci "$@"
speech_box::log::info "--- CI ---"
vox_box::log::info "--- CI ---"
6 changes: 3 additions & 3 deletions hack/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source "${ROOT_DIR}/hack/lib/init.sh"

function download_deps() {
git submodule update --init --recursive
rm -rf "${ROOT_DIR}/speech_box/third_party/CosyVoice/third_party/Matcha-TTS/data"
rm -rf "${ROOT_DIR}/vox_box/third_party/CosyVoice/third_party/Matcha-TTS/data"

pip install poetry==1.8.3 pre-commit==4.0.1
poetry install
Expand All @@ -24,6 +24,6 @@ function download_deps() {
# main
#

speech_box::log::info "+++ DEPENDENCIES +++"
vox_box::log::info "+++ DEPENDENCIES +++"
download_deps
speech_box::log::info "--- DEPENDENCIES ---"
vox_box::log::info "--- DEPENDENCIES ---"
4 changes: 2 additions & 2 deletions hack/lib/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ for file in "${ROOT_DIR}/hack/lib/"*; do
fi
done

speech_box::log::install_errexit
speech_box::version::get_version_vars
vox_box::log::install_errexit
vox_box::version::get_version_vars
20 changes: 10 additions & 10 deletions hack/lib/log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ log_level="${LOG_LEVEL:-"debug"}"
log_colorful="${LOG_COLORFUL:-"true"}"

# Handler for when we exit automatically on an error.
speech_box::log::errexit() {
vox_box::log::errexit() {
local err="${PIPESTATUS[*]}"

# if the shell we are in doesn't have errexit set (common in subshells) then
# don't dump stacks.
set +o | grep -qe "-o errexit" || return

set +o xtrace
speech_box::log::panic "${BASH_SOURCE[1]}:${BASH_LINENO[0]} '${BASH_COMMAND}' exited with status ${err}" "${1:-1}"
vox_box::log::panic "${BASH_SOURCE[1]}:${BASH_LINENO[0]} '${BASH_COMMAND}' exited with status ${err}" "${1:-1}"
}

speech_box::log::install_errexit() {
vox_box::log::install_errexit() {
# trap ERR to provide an error handler whenever a command exits nonzero, this
# is a more verbose version of set -o errexit
trap 'speech_box::log::errexit' ERR
trap 'vox_box::log::errexit' ERR

# setting errtrace allows our ERR trap handler to be propagated to functions,
# expansions and subshells
set -o errtrace
}

# Debug level logging.
speech_box::log::debug() {
vox_box::log::debug() {
[[ ${log_level} == "debug" ]] || return 0
local message="${2:-}"

Expand All @@ -50,7 +50,7 @@ speech_box::log::debug() {
}

# Info level logging.
speech_box::log::info() {
vox_box::log::info() {
[[ ${log_level} == "debug" ]] || [[ ${log_level} == "info" ]] || return 0
local message="${2:-}"

Expand All @@ -68,7 +68,7 @@ speech_box::log::info() {
}

# Warn level logging.
speech_box::log::warn() {
vox_box::log::warn() {
local message="${2:-}"

local timestamp
Expand All @@ -85,7 +85,7 @@ speech_box::log::warn() {
}

# Error level logging, log an error but keep going, don't dump the stack or exit.
speech_box::log::error() {
vox_box::log::error() {
local message="${2:-}"

local timestamp
Expand All @@ -102,7 +102,7 @@ speech_box::log::error() {
}

# Fatal level logging, log an error but exit with 1, don't dump the stack or exit.
speech_box::log::fatal() {
vox_box::log::fatal() {
local message="${2:-}"

local timestamp
Expand All @@ -125,7 +125,7 @@ speech_box::log::fatal() {
# $1 Message to log with the error
# $2 The error code to return
# $3 The number of stack frames to skip when printing.
speech_box::log::panic() {
vox_box::log::panic() {
local message="${1:-}"
local code="${2:-1}"

Expand Down
12 changes: 6 additions & 6 deletions hack/lib/util.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env bash


function speech_box::util::sed() {
function vox_box::util::sed() {
if ! sed -i "$@" >/dev/null 2>&1; then
# back off none GNU sed
sed -i "" "$@"
fi
}

function speech_box::util::get_os_name() {
function vox_box::util::get_os_name() {
# Support overriding by BUILD_OS for cross-building
local os_name="${BUILD_OS:-}"
if [[ -n "$os_name" ]]; then
Expand All @@ -18,10 +18,10 @@ function speech_box::util::get_os_name() {
fi
}

function speech_box::util::is_darwin() {
[[ "$(speech_box::util::get_os_name)" == "darwin" ]]
function vox_box::util::is_darwin() {
[[ "$(vox_box::util::get_os_name)" == "darwin" ]]
}

function speech_box::util::is_linux() {
[[ "$(speech_box::util::get_os_name)" == "linux" ]]
function vox_box::util::is_linux() {
[[ "$(vox_box::util::get_os_name)" == "linux" ]]
}
2 changes: 1 addition & 1 deletion hack/lib/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# it can be specified via "VERSION".
# BUILD_DATE - The build date of the version.

function speech_box::version::get_version_vars() {
function vox_box::version::get_version_vars() {
#shellcheck disable=SC2034
BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
GIT_TREE_STATE="unknown"
Expand Down
8 changes: 4 additions & 4 deletions hack/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ source "${ROOT_DIR}/hack/lib/init.sh"
function lint() {
local path="$1"

speech_box::log::info "linting ${path}"
vox_box::log::info "linting ${path}"
pre-commit run --all-files
}

#
# main
#

speech_box::log::info "+++ LINT +++"
lint "speech_box"
speech_box::log::info "--- LINT ---"
vox_box::log::info "+++ LINT +++"
lint "vox_box"
vox_box::log::info "--- LINT ---"
4 changes: 2 additions & 2 deletions hack/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ function test() {
# main
#

speech_box::log::info "+++ TEST +++"
vox_box::log::info "+++ TEST +++"
test
speech_box::log::info "--- TEST ---"
vox_box::log::info "--- TEST ---"
4 changes: 2 additions & 2 deletions hack/windows/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Install-Dependency {
}

function Set-Version {
$versionFile = Join-Path -Path $ROOT_DIR -ChildPath "speech_box\__init__.py"
$versionFile = Join-Path -Path $ROOT_DIR -ChildPath "vox_box\__init__.py"
$version = if ($null -ne $global:GIT_VERSION) { $global:GIT_VERSION } else { "0.0.0" }
$gitCommit = if ($null -ne $global:GIT_COMMIT) { $global:GIT_COMMIT } else { "HEAD" }
$gitCommitShort = $gitCommit.Substring(0, [Math]::Min(7, $gitCommit.Length))
Expand All @@ -55,7 +55,7 @@ function Set-Version {
}

function Restore-Version-File {
$versionFile = Join-Path -Path $ROOT_DIR -ChildPath "speech_box\__init__.py"
$versionFile = Join-Path -Path $ROOT_DIR -ChildPath "vox_box\__init__.py"

git checkout -- $versionFile
if ($LASTEXITCODE -ne 0) {
Expand Down
2 changes: 1 addition & 1 deletion hack/windows/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $ROOT_DIR = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent | Split-

function Install-Dependency {
git submodule update --init --recursive
Remove-Item -Recurse -Force "$ROOT_DIR/speech_box/third_party/CosyVoice/third_party/Matcha-TTS/data"
Remove-Item -Recurse -Force "$ROOT_DIR/vox_box/third_party/CosyVoice/third_party/Matcha-TTS/data"

pip install poetry==1.8.3 pre-commit==4.0.1
if ($LASTEXITCODE -ne 0) {
Expand Down
2 changes: 1 addition & 1 deletion hack/windows/lint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Lint {
SpeechBox.Log.Info "+++ LINT +++"
try {
Get-PSScriptAnalyzer
Lint "speech_box"
Lint "vox_box"
}
catch {
SpeechBox.Log.Fatal "failed to lint: $($_.Exception.Message)"
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "speech_box"
name = "vox_box"
version = "0.0.0"
description = "Speech box"
description = "Vox box"
authors = ["GPUStack Authors <[email protected]>"]
readme = "README.md"

Expand Down Expand Up @@ -87,4 +87,4 @@ requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
speech-box = "speech_box.main:main"
vox-box = "vox_box.main:main"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC, abstractmethod
from typing import Dict, List, Optional
from speech_box.config.config import Config
from vox_box.config.config import Config


class STTBackend(ABC):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from typing import Dict, List, Optional
import tempfile
import io
from speech_box.backends.stt.base import STTBackend
from speech_box.config.config import BackendEnum, Config, TaskTypeEnum
from speech_box.utils.log import log_method
from speech_box.utils.model import create_model_dict
from vox_box.backends.stt.base import STTBackend
from vox_box.config.config import BackendEnum, Config, TaskTypeEnum
from vox_box.utils.log import log_method
from vox_box.utils.model import create_model_dict
from faster_whisper.transcribe import WhisperModel

logger = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import os
from typing import Dict, List, Optional
import tempfile
from speech_box.backends.stt.base import STTBackend
from speech_box.config.config import BackendEnum, Config, TaskTypeEnum
from speech_box.utils.log import log_method
from speech_box.utils.model import create_model_dict
from vox_box.backends.stt.base import STTBackend
from vox_box.config.config import BackendEnum, Config, TaskTypeEnum
from vox_box.utils.log import log_method
from vox_box.utils.model import create_model_dict


logger = logging.getLogger(__name__)
Expand Down
10 changes: 5 additions & 5 deletions speech_box/backends/tts/bark.py → vox_box/backends/tts/bark.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import tempfile
from typing import Dict, List, Optional

from speech_box.backends.tts.base import TTSBackend
from speech_box.config.config import BackendEnum, Config, TaskTypeEnum
from vox_box.backends.tts.base import TTSBackend
from vox_box.config.config import BackendEnum, Config, TaskTypeEnum
from transformers import AutoProcessor, BarkModel
from scipy.io.wavfile import write as write_wav

from speech_box.utils.ffmpeg import convert
from speech_box.utils.log import log_method
from speech_box.utils.model import create_model_dict
from vox_box.utils.ffmpeg import convert
from vox_box.utils.log import log_method
from vox_box.utils.model import create_model_dict


class Bark(TTSBackend):
Expand Down
Loading

0 comments on commit ed7bdda

Please sign in to comment.