repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | #!/usr/bin/env bash |
| #2 | set -euo pipefail |
| #3 | |
| #4 | usage() { |
| #5 | cat >&2 <<'EOF' |
| #6 | Usage: |
| #7 | transcribe.sh <audio-file> [--model whisper-1] [--out /path/to/out.txt] [--language en] [--prompt "hint"] [--json] |
| #8 | EOF |
| #9 | exit 2 |
| #10 | } |
| #11 | |
| #12 | if [[ "${1:-}" == "" || "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then |
| #13 | usage |
| #14 | fi |
| #15 | |
| #16 | in="${1:-}" |
| #17 | shift || true |
| #18 | |
| #19 | model="whisper-1" |
| #20 | out="" |
| #21 | language="" |
| #22 | prompt="" |
| #23 | response_format="text" |
| #24 | |
| #25 | while [[ $# -gt 0 ]]; do |
| #26 | case "$1" in |
| #27 | --model) |
| #28 | model="${2:-}" |
| #29 | shift 2 |
| #30 | ;; |
| #31 | --out) |
| #32 | out="${2:-}" |
| #33 | shift 2 |
| #34 | ;; |
| #35 | --language) |
| #36 | language="${2:-}" |
| #37 | shift 2 |
| #38 | ;; |
| #39 | --prompt) |
| #40 | prompt="${2:-}" |
| #41 | shift 2 |
| #42 | ;; |
| #43 | --json) |
| #44 | response_format="json" |
| #45 | shift 1 |
| #46 | ;; |
| #47 | *) |
| #48 | echo "Unknown arg: $1" >&2 |
| #49 | usage |
| #50 | ;; |
| #51 | esac |
| #52 | done |
| #53 | |
| #54 | if [[ ! -f "$in" ]]; then |
| #55 | echo "File not found: $in" >&2 |
| #56 | exit 1 |
| #57 | fi |
| #58 | |
| #59 | if [[ "${OPENAI_API_KEY:-}" == "" ]]; then |
| #60 | echo "Missing OPENAI_API_KEY" >&2 |
| #61 | exit 1 |
| #62 | fi |
| #63 | |
| #64 | if [[ "$out" == "" ]]; then |
| #65 | base="${in%.*}" |
| #66 | if [[ "$response_format" == "json" ]]; then |
| #67 | out="${base}.json" |
| #68 | else |
| #69 | out="${base}.txt" |
| #70 | fi |
| #71 | fi |
| #72 | |
| #73 | mkdir -p "$(dirname "$out")" |
| #74 | |
| #75 | curl -sS https://api.openai.com/v1/audio/transcriptions \ |
| #76 | -H "Authorization: Bearer $OPENAI_API_KEY" \ |
| #77 | -H "Accept: application/json" \ |
| #78 | -F "file=@${in}" \ |
| #79 | -F "model=${model}" \ |
| #80 | -F "response_format=${response_format}" \ |
| #81 | ${language:+-F "language=${language}"} \ |
| #82 | ${prompt:+-F "prompt=${prompt}"} \ |
| #83 | >"$out" |
| #84 | |
| #85 | echo "$out" |
| #86 |