mirror of
https://github.com/D-Modem/speaking-clock.git
synced 2026-11-28 20:48:04 -08:00
Merge pull request #5 from D-Modem/claude/project-thread-zoxpz9
Add a top-level Makefile that builds the modules and installs the voices
This commit is contained in:
4 files changed
+124
-2
No files matched your search
@@ -0,0 +1,96 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Builds and installs everything: the PBX modules, our synthesisers and the
|
||||
# voices.
|
||||
#
|
||||
# make build the modules for the PBXs found here, the
|
||||
# synthesisers, sclock-render, and fetch the
|
||||
# Microsoft and Apple voice data
|
||||
# sudo make install install the modules, their configs, voices/, and
|
||||
# the synthesisers with their voice data
|
||||
# make test render 30 seconds of a voice with sclock-render
|
||||
# make clean remove what make built (keeps sources/)
|
||||
# make distclean also remove the downloaded voice data
|
||||
#
|
||||
# Settings:
|
||||
# PBX="asterisk freeswitch" which modules to build (default: the PBXs
|
||||
# whose headers are installed)
|
||||
# FETCH=no don't download the voice data; the live
|
||||
# mssam, macintalk and plaintalk voices then
|
||||
# won't speak until it is fetched
|
||||
# SYNTH=no skip synth/mssam and synth/macintalk
|
||||
# PREFIX=/usr/local where the synthesisers go
|
||||
# DESTDIR=... staging root, for packaging
|
||||
# and the sub-makes' own: ASTERISK_INCLUDE, FS_INCLUDE, MODULES_DIR,
|
||||
# CONF_DIR, SOUNDS_DIR (see asterisk/Makefile and freeswitch/Makefile).
|
||||
#
|
||||
# Microsoft's and Apple's voice files are not in this repository: they are
|
||||
# downloaded from the Internet Archive into sources/ (tools/fetch-mssam.py,
|
||||
# tools/fetch-macintalk.py). The PlainTalk voices need unar or unrar, and
|
||||
# the Microsoft voices cabextract or 7z.
|
||||
|
||||
PREFIX ?= /usr/local
|
||||
FETCH ?= yes
|
||||
SYNTH ?= yes
|
||||
|
||||
# PBXs whose headers are installed
|
||||
HAVE_ASTERISK := $(if $(ASTERISK_INCLUDE),$(wildcard $(ASTERISK_INCLUDE)/asterisk.h),$(wildcard /usr/include/asterisk.h))
|
||||
HAVE_FREESWITCH := $(or $(shell pkg-config --exists freeswitch 2>/dev/null && echo yes), \
|
||||
$(if $(FS_INCLUDE),$(wildcard $(FS_INCLUDE)/switch.h)), \
|
||||
$(wildcard /usr/include/freeswitch/switch.h /usr/local/freeswitch/include/freeswitch/switch.h))
|
||||
PBX ?= $(if $(HAVE_ASTERISK),asterisk) $(if $(HAVE_FREESWITCH),freeswitch)
|
||||
PBX := $(strip $(PBX))
|
||||
|
||||
SYNTHS := $(if $(filter yes,$(SYNTH)),mssam macintalk)
|
||||
VOICEDATA := $(if $(filter yes,$(FETCH)),$(addprefix voices-,$(SYNTHS)))
|
||||
SUBMAKE = $(MAKE) PREFIX=$(PREFIX)
|
||||
|
||||
all: check-pbx $(PBX) $(SYNTHS) core $(VOICEDATA)
|
||||
|
||||
check-pbx:
|
||||
@if [ -z "$(PBX)" ]; then \
|
||||
echo "No Asterisk or FreeSWITCH headers found: building only the synthesisers"; \
|
||||
echo "and sclock-render. Install asterisk-dev or libfreeswitch-dev, or set"; \
|
||||
echo "PBX=asterisk / PBX=freeswitch with ASTERISK_INCLUDE= / FS_INCLUDE=."; \
|
||||
else echo "Building for: $(PBX)"; fi
|
||||
|
||||
asterisk freeswitch core:
|
||||
$(MAKE) -C $@
|
||||
|
||||
mssam macintalk:
|
||||
$(SUBMAKE) -C synth/$@
|
||||
|
||||
voices-mssam voices-macintalk:
|
||||
$(SUBMAKE) -C synth/$(@:voices-%=%) voices
|
||||
|
||||
# voices/ goes into each PBX's sounds directory with its module
|
||||
install: all $(addprefix install-,$(PBX)) $(if $(VOICEDATA),$(addprefix install-,$(SYNTHS)),$(addprefix install-bin-,$(SYNTHS)))
|
||||
|
||||
install-asterisk install-freeswitch:
|
||||
$(MAKE) -C $(@:install-%=%) install
|
||||
|
||||
install-mssam install-macintalk:
|
||||
$(SUBMAKE) -C synth/$(@:install-%=%) install
|
||||
|
||||
# FETCH=no: the program only; its voice data can be installed later
|
||||
install-bin-mssam install-bin-macintalk:
|
||||
install -d $(DESTDIR)$(PREFIX)/bin
|
||||
install -m 755 synth/$(@:install-bin-%=%)/$(@:install-bin-%=%) $(DESTDIR)$(PREFIX)/bin/
|
||||
|
||||
test: core
|
||||
cd core && ./sclock-render -v ../voices tim-pat-simmons 1762791295 30 /tmp/sclock-test.sln Europe/London
|
||||
@echo "/tmp/sclock-test.sln (8 kHz signed linear)"
|
||||
|
||||
clean:
|
||||
$(MAKE) -C asterisk clean
|
||||
$(MAKE) -C freeswitch clean
|
||||
$(MAKE) -C core clean
|
||||
$(MAKE) -C synth/mssam clean
|
||||
$(MAKE) -C synth/macintalk clean
|
||||
|
||||
distclean: clean
|
||||
rm -rf sources/mssam sources/macintalk
|
||||
|
||||
.PHONY: all check-pbx asterisk freeswitch core mssam macintalk \
|
||||
voices-mssam voices-macintalk install install-asterisk install-freeswitch \
|
||||
install-mssam install-macintalk install-bin-mssam install-bin-macintalk \
|
||||
test clean distclean
|
||||
@@ -25,6 +25,28 @@ It has these voices, and each voice can give the time to the second:
|
||||
The recordings in `voices/` belong to their original owners, and **are not
|
||||
covered by the code's licence**. Refer to [NOTICE.md](NOTICE.md).
|
||||
|
||||
## Building and installing
|
||||
|
||||
From the top of the repository:
|
||||
|
||||
```sh
|
||||
make # modules for the PBXs found here, synth/mssam, synth/macintalk,
|
||||
# sclock-render, and the Microsoft and Apple voice data
|
||||
sudo make install # modules, configs, voices/ into each PBX's sounds/speaking-clock,
|
||||
# and the synthesisers with their voice data under /usr/local
|
||||
make test # render 30 seconds of Pat Simmons with sclock-render
|
||||
```
|
||||
|
||||
It builds `app_speakingclock` if Asterisk's headers are installed and
|
||||
`mod_speakingclock` if FreeSWITCH's are. `make PBX="asterisk freeswitch"`
|
||||
picks them yourself (with `ASTERISK_INCLUDE=` or `FS_INCLUDE=` for headers
|
||||
somewhere else). Microsoft's and Apple's voice files are not in this
|
||||
repository: `make` downloads them from the Internet Archive into
|
||||
`sources/` (cabextract or 7z for Microsoft's, unar or unrar for the
|
||||
PlainTalk voices). `FETCH=no` skips the download, `SYNTH=no` skips the
|
||||
synthesisers, and `PREFIX=` and `DESTDIR=` work as usual. The sections
|
||||
below build one part at a time.
|
||||
|
||||
## How it keeps time
|
||||
|
||||
The old machines played one recording, and all callers listened to it.
|
||||
|
||||
@@ -10,7 +10,7 @@ CFLAGS ?= -O2 -Wall -Wextra -Wno-missing-field-initializers
|
||||
SOURCES ?= ../../sources/macintalk
|
||||
|
||||
macintalk: macintalk.c plaintalk.c rules.h
|
||||
$(CC) $(CFLAGS) -o $@ macintalk.c -lm
|
||||
$(CC) $(CFLAGS) -DVOICEDIR='"$(VOICEDIR)"' -o $@ macintalk.c -lm
|
||||
|
||||
voices: $(SOURCES)/fred.ttvd
|
||||
|
||||
|
||||
@@ -1203,9 +1203,13 @@ static int write_wav(FILE *f, const float *x, int n)
|
||||
return ferror(f) ? -1 : 0;
|
||||
}
|
||||
|
||||
#ifndef VOICEDIR
|
||||
#define VOICEDIR "/usr/local/share/macintalk"
|
||||
#endif
|
||||
|
||||
static const char *default_dir(void)
|
||||
{
|
||||
static const char *dirs[] = { "/usr/local/share/macintalk", "/usr/share/macintalk",
|
||||
static const char *dirs[] = { VOICEDIR, "/usr/local/share/macintalk", "/usr/share/macintalk",
|
||||
"sources/macintalk", NULL };
|
||||
const char *e = getenv("MACINTALK_VOICES");
|
||||
int i;
|
||||
|
||||
Reference in new issue
Block a user