Commit graph

194 commits

Author SHA1 Message Date
Solomon Peachy
92b80bdba5 lang: Support languages that speak the units before a numerical value
Previously, it was hardcoded to the english convention of units-last, so
"100%" would be voiced as "one hundred percent".  This adds a new
language flag that makes the units be voiced first, ie "100%" will be
voiced as "percent one hundred".

So far only the Chinese-traditional and Chinese-simplified languages
utilize this feature (taken from an old ticket, FS#10340) but I'm sure
others would want this feature too.

Change-Id: Idf825ec9299dc0ed09921cf67aec61b1ab262fc6
2023-05-22 10:30:13 -04:00
Aidan MacDonald
1e9ad3ca0d Remove buflib allocation names, part two
Remove allocation names from the buflib API and fix up all callers.

Change-Id: I3df922e258d5f0d711d70e72b56b4ed634fb0f5a
2023-01-13 10:32:54 +00:00
Aidan MacDonald
701e262d3d settings: Remove setting ID return from find_setting()
Now that all users have replaced setting IDs with direct pointers,
find_setting() and friends don't need to return an ID value.

Change-Id: I8c5c31bb68d3bca5350d43538335265a55fd5517
2022-12-17 13:36:38 +00:00
William Wilgus
3745c813f9 misc.c open_pathfmt caller supplied buffer
Amachronic raised concern about open() blocking causing a static buf
to get overwritten in multiple calls its prudent to just have the caller
supply the buffer to minimize stack issues later

Change-Id: Iae27c7d063adb1a65688f920f6aa5c395fa5694a
2022-11-23 22:09:46 -05:00
William Wilgus
e7e20fab1b create function open_pathfmt() to allow printf formatting on open()
save some space by allowing printf formatting directly rather than
having a buffer and using sprintf

Change-Id: I049c8f898fb4a68a26ad0f0646250c242647ba12
2022-11-19 23:13:42 -05:00
William Wilgus
3b1230b365 talk.c add busy loop to talk_spell
talk spell can lose the remainder of the words on longer sequences

Change-Id: I5f8f0f42d780ea9d1f00d99ff32746be34c27745
2022-11-19 02:13:51 -05:00
William Wilgus
b0ccb1b95f talk.c clean up
Change-Id: Ie06859c80e9ca14bf3e4a23b82d3d1c76263b2b8
2022-11-19 02:12:09 -05:00
William Wilgus
f6c719d7ec replace strlcpy with strmemccpy
replace applicable calls to strlcpy with calls to strmemccpy
which null terminates on truncation

in theory the strmemccpy calls should be slightly faster since they
don't traverse the rest of the source string on truncation
but I seriously doubt there is too much of that going on in the code base

Change-Id: Ia0251514e36a6242bbf3f03c5e0df123aba60ed2
2022-11-14 23:56:16 -05:00
William Wilgus
034b6d5bfb Remove some shadowed variables identified by -Wshadow
there are plenty more but these are the low hanging fruit

Change-Id: I86d9f4f56e8cd9b381d1bf6a6679cd58c6a4004d
2022-11-14 09:01:43 -05:00
William Wilgus
12ef045fdf move buflib_free invalid handle check to the function
allow buflib_free to check for invalid or already freed handles
within the function -- remove all the invalid handle guards thru core_free

Change-Id: Ibdcbc82760fc93b674c42283fca420d94907df8e
2022-10-15 09:26:58 -04:00
Aidan MacDonald
dadfbfc6a5 apps: fix close of negative fd in talk.c
Bug reported by UBSan.

Change-Id: I02276521510acac8696499895fec15993c55aaf6
2022-05-02 16:34:18 +01:00
Solomon Peachy
eeacffbd15 voice: Allow voiced date format to be overridden
This adds LANG_VOICED_DATE_FORMAT, a format string with these tokens:

 Y  4-digit year
 A  Month name
 m  numeric month
 d  numeric day of month

The default (english) is '23 January 2013'
In comparison, english-us is 'January 23 2013'

Change-Id: I055a3287c104260dec63bba58d36fdae9df1ed16
2021-09-28 21:58:11 -04:00
Solomon Peachy
70e72e01d2 talk: Add support for languages that swap the tens position in numbers
For example, English would say "231" as "two hundred thirty one" but
many other languages would say "two hundred one and thirty"

So, if VOICE_NUMERIC_TENS_SWAP_SEPARATOR is not an empty string, swap
the tens and ones position and use that string ("and" in the above
example) as the voiced separator.

Change-Id: I69f8064d44b3995827327cabae6ad352bf257d04
2021-09-28 17:25:28 -04:00
William Wilgus
26fd90bb49 talk.c check for proper file load
few sanity checks on voice clip loads

Change-Id: I15fdf05d2964e9f6d00360b9730357dac6054af7
2021-07-23 22:53:25 +00:00
William Wilgus
8cd4b8da84 talk.c check for 0 talk clips file descriptor leaks & announce_status fix typo
talk.c potential division by zero warrants a check

desowin pointed out multiple fd leaks

announce_status.c dumb typo

Change-Id: Iae99bd64696afdd9585952245a7a04cdc9f88ef1
2021-07-21 11:26:29 +00:00
Solomon Peachy
a952cf52d5 voice: Corrections to 24-hour time voicing:
* Voice leading "Oh" if hours is under 10.

 (ie "0900" is read as "oh nine hundred hours"

Change-Id: I09853909221e0dd6da354f7e4bb9733ff5edca90
2021-07-08 10:57:57 -04:00
William Wilgus
895ed92496 Talk.c, playlist.c fix bugs
fix bug in talk.c

playlist.c only dump voice buffer if we are out of space

Change-Id: I75705d755db4193a87e542d062dbdc96b153dbb6
2021-03-04 23:31:32 -05:00
William Wilgus
10b6707131 Talk Fix outright disable after first clip
Oops Sorry bout that ;P

Change-Id: I2618e2565a218dd5640351dfef3b7cc2a64617d4
2021-03-04 21:57:21 -05:00
William Wilgus
b2732222e9 Talk.c Guard against use after free / failure to load voicefile
load_voicefile_data wasn't checked for success leading
to a use after free situation

get_clip now checks for valid index_handle before using it

Change-Id: Id66dba6dbd6becfc9e0fe922fbc1d0adec1f0393
2021-03-05 02:22:20 +00:00
Solomon Peachy
ca326896d0 Fix compile warnings (set-but-not-used) on big endian targets
Change-Id: Ia433122d6c0af68a47d2f4a531a0787a9d3d9f72
2020-10-13 13:37:23 -04:00
William Wilgus
1f9e16e4df InvalidVoice prompt Fix red for devices w/o physical hold buttons
left in there from debugging

Change-Id: I6b9b7cb92848d2a7a72f6b1d688e61dc81c7c27b
2020-09-20 16:44:24 -04:00
William Wilgus
2ffe87902d Add Invalid Voice Announcement to the voice system FS#13216
When a voice file is invalid or fails to load the voice system splash a
message 'Invalid Voice'

Now we supply a single voice file (currently only english is used)
the support for other languages is in but I haven't set it up to
look for anything but InvalidVoice_english.talk

Also adds a one time kill voice thread function
 ie. it doesn't allow re-init after killing the voice thread & queue

Change-Id: I7b43f340c3cc65c65110190f0e0075b31218a7ac
2020-09-20 16:08:49 -04:00
Solomon Peachy
5d40d97585 voice: rename mp3_play_* functions to voice_play_*
Remove mp3_is_playing() entirely, in favor of pcm_is_playing()
Remove mp3_play_pause() entirely, as it's a dummy/no-op call
Remoce some archos-specific comments

Change-Id: I4e9ff323490a93add00809efd19e0d4e3f198b2d
2020-09-20 14:52:30 +00:00
Solomon Peachy
8cb555460f [3/4] Completely remove HWCODEC support
'swcodec' is now always set (and recording_swcodec for recording-capable
units) in feature.txt so the manual and language strings don't need to
all be fixed up.

Change-Id: Ib2c9d5d157af8d33653e2d4b4a12881b9aa6ddb0
2020-07-24 21:20:13 +00:00
Solomon Peachy
092c340a20 [1/4] Remove SH support and all archos targets
This removes all code specific to SH targets

Change-Id: I7980523785d2596e65c06430f4638eec74a06061
2020-07-24 21:20:13 +00:00
Solomon Peachy
09f40e266b talk: Force-shutdown the voice system before loading a new voice
Otherwise we might actually be talking when we try to switch, or
otherwise trash the state of the running talk thread, leading to
memory corruption or an outright crash

(This fixes a panic observed on the xDuoo X3)

Change-Id: I78e4232085c5c160c9ee4f18167dad8dad2b9287
2020-07-24 03:31:11 +00:00
Solomon Peachy
a5df94beb5 build: Tweaks to better support non-English as primary language
* get rid of $(LANGUAGE) in top-level makefile (and configure script)
 * un-hardcode English-as-primary-language in a couple more places
 * allow DEFAULT_VOICE_LANG to be overriden

To actually change the primary from English, one must change:

 * $english in voice.pl
 * hardcoded 'english' in rbutil
 * $ENGLISH in apps/lang/lang.make
 * DEFAULT_VOICE_LANG in apps/talk.c
 * configure script (default prompt)

Of course, if one wants to change the default UI language, it's simpler
to change the default language setting variable at compile time, or
perhaps by adding a configuration file with the desired value into the
.rockbox directory when the .zip is assembled.

Change-Id: If5cf76019d416e838628a2eccd4ec7d6cbaeeb74
2020-07-21 17:22:45 +00:00
Solomon Peachy
688c89cfe1 genlang: More voice-related fixes.
* Use consistent ID numbering
 * Use consistent logic for voicelist and voicebin files
 * Fix situations where English <-> English would fail in strange ways
 * Delete leftover tmpfile.
 * Off-by-one error in voice validation code
 * Off-by-one error in voicelist generation

Change-Id: Ib3cea2c6612138b1cbe614dacbe51000199cc9ad
2020-07-21 11:59:47 +00:00
Solomon Peachy
0e97132314 talk: only show the "failed reading .voice" splash if talking is enabled
Change-Id: I4046294e39c621ddeeceeb6f21eab05a1e687cb5
2020-07-15 03:02:28 +00:00
Peter Sealy
b64a286a81 voice file not loading
>
> I ran into an issue where my voice file would only load if I changed language while playing music. It seems to happen because when no other file is open, file.c alloc_filestr returns the first free handle which is 0. In talk.c this is treated as an invalid handle, so the voice file is not loaded.

Change-Id: I42db40b10cc7a900bdd72012d99265300e783e44
2020-07-09 14:07:37 +00:00
William Wilgus
dcf8154c32 talk.h add failed to load splash
Change-Id: Ie355a52bb6c687d302dc3e39693b9ab40e2dd699
2020-05-22 07:52:01 -05:00
William Wilgus
74f358cf8b talk.h add init status to debug menu
g#2272 adds checks for incompatible version & proper number of clips

Currently incompatible talk files will logf when failure to load occurs

Adds a message to Debug > Talk engine stats
'Talk Status: OK'
'Talk Status: ERR Incompatible voice file'
'Talk Status: ERR (#)' -- OOM, Alloc Error

Change-Id: Ifd2c1f38f710541c9cd929b8abf67bba4363ca53
2020-05-22 06:35:22 -05:00
William Wilgus
c93666d08e talk.h make voice files check for proper number of entries on load
In addition to version and target also check id1_max & id2_max
for proper length before allowing voice file to be loaded

Change-Id: I36016059d07781b0bb43dd9873bbb6e565298d76
2020-04-17 07:30:23 +02:00
Solomon Peachy
e6b03ffa82 Respect age when freeing thumbnails from clip cache.
Otherwise they could get freed while queued.

Patch by Igor Poretsky

Change-Id: I436b074d81a85cfeb68a07a17320a3c9c0a43e1e
2019-08-06 13:37:20 +02:00
Solomon Peachy
3b7ae5e06b Improved robustness in talk code
Patch by Igor Poretsky

Change-Id: I5c0dcc693b647c7573379e33406a7b9d4b192725
2019-08-05 05:01:11 +02:00
Solomon Peachy
55eb1c54eb FS#7704 - Talk support for plugins
Original patch by Mario Lang
Heavily updated by Igor Poretsky
Further updated by myself

  This patch breaks binary API compatibility by placing the new
  functions where they make the most logical sense. IMO this is
  the better approach to take given the scope of the changes needed
  for talk support.

  Since binary API is changing, the patch also moves some other
  functions around to more logical locations.

  As well as voice support in plugins, this patch voice-enables several
  simple plugins.  There will be follow-up patches for many plugins that
  build on this one.

Change-Id: I18070c06e77e8a3c016c2eb6b6c5dbe6633b9b54
2019-07-20 08:48:35 +02:00
William Wilgus
a06d9c85f7 Auto-Ranging Time Formatting For Menus (hh:mm:ss:mss)
Unifies time formatting in settings_list.c allows time format to
display as HH:MM:SS.MSS or any consecutive combination thereof
(hh:mm:ss, mm:ss, mm:ss.mss, ss.mss, hh, mm, ss ,mss)
works in INT and TABLE settings with the addition of flag 'F_TIME_SETTING'

Time is auto-ranged dependent on value

Adds talk_time_intervals to allow time values to be spoken similar to
display format:  x Hours, x Minutes, x Seconds, x Milliseconds

Table lookups merged or removed from recording, clip meter and lcd timeout
-String_Choice replaced with TABLE_SETTING or INT_SETTING for these
functions as well, cleaned-up cfg_vals that get saved to cfgfile

RTL Languages ARE supported

Negative values ARE supported

Backlight on/off are now Always and Never to share formatter with LCD
Timeout

Added flag to allow ranged units to be locked to a minimum index

Added flag to allow leading zero to be supressed from the largest unit

merged talk_time_unit() and talk_time_intervals()

optimized time_split()

optimized format_time_auto()

Backlight time-out list same as original

Change-Id: I59027c62d3f2956bd16fdcc1a48b2ac32c084abd
2018-12-22 12:27:21 -06:00
Solomon Peachy
c2308bdf40 Fix HWCODEC builds.
Change-Id: I7abed5dab9b4d0d053c274404dc4dc06864aa060
2018-12-15 13:09:51 -05:00
Solomon Peachy
4adad0bc1f FS#6323: Speech for ID3 viewer, playlist catalog and playlist viewer
Modified from original ticket, Taken from Igor Poretsky's tree, and
further modified by myself to incorporate feedback.

Change-Id: Ibc2180e52af76890b1448d23f79386fd0f88f709
2018-12-15 18:00:23 +01:00
William Wilgus
62a5ed49cc Fix possible truncation misc.c->output_dyn_value + use Kibytes
output_dyn_value now requires the count for number of units

Binary scale now shows Kibibytes instead of kilobytes (g#1742)

Fixes output for negative values as well

Change-Id: I8aa896860e97d2453fa35069e2dfe1caac60109f
2018-12-09 22:54:55 -06:00
Thomas Martitz
0b7a90722a talk: On hwcodec disabling DMA interrupt is required during buflib move
Even though the DMA buffer itself does not move the ISR copies from a movable
buffer into the static commit buffer. To ensure this copying yields consistent
data it must not be interrupted by this ISR..

Also bump the commit buffer size to 2k, this should reduce the overhead
considerably because many clips are smaller than that (especially on
swcodec/speex).

Change-Id: I4e1ab83074f31fc91b51a58baa1df55ce659ac73
2014-02-03 12:43:05 +01:00
Thomas Martitz
10b3bc78f6 Fix warnings.
Change-Id: If3cbcd7557797684f1b7fea8e1bb134777680dee
2014-02-03 12:33:33 +01:00
Thomas Martitz
e5eb74592e talk/voice: Reduce the size of the commit buffer.
The voice engine can now request more voice data during decoding, it does
not require the entire clip to be available before start of decoding anymore.
Therefore the commit buffer does not need to hold an entire voice clip anymore,
and can be made greatly smaller.

Change-Id: I3eca9026448e725b9b8d0dae1efca0ad185371da
2014-02-02 19:40:39 +01:00
Thomas Martitz
af02a674c5 talk.c: The new cache management is good enough to use it for .talk clips as well.
This unifies the talk.c for all possible voice payload. .talk clips are placed
onto the same unified clip cache, along with normal clips. This allows for more
effecient memory usage.

The cache handling makes a slight difference between normal clips and .talk
ones: .talk clips can be cached multiple and are always freed first.The extra
logic to avoid loading multiple copies of .talks is not necessary because the
will be freed first anyway.

Change-Id: I88d056a0a613b129f5875f50fdb757b58bac0a42
2014-02-02 19:40:39 +01:00
Thomas Martitz
03f373c9cd talk.c: The new cache management is good enough to use it on all targets.
This unifies the talk.c for all targets. The only separation is left is
TALK_PROGRESSIVE_LOAD: When this is defined the talk buffer will not be
initially prefilled. This is useful for super slow storage or when the buffer
is not large enough to prefill it with useful clips (the prefill code could
be made smarter too).

The buffer size can be adjusted. By default lowmem uses 100k while
other targets load the entire file. The bigger the more clips can be cached
but with diminishing returns.

Change-Id: Ife38fb101c53093117e6638c40c65f7d177a31d4
2014-02-02 19:40:39 +01:00
Thomas Martitz
c46f9be10a talk: Smarter cache management for TALK_PARTIAL_LOAD.
Previously the clip cache of TALK_PARTIAL_LOAD reserved space N clips, each slot
was as big as the maximum sized clip which was necessary to replace clips
in-memory in MRU-style.

The cache management now uses buflib to allocate and free each clip, using the
clip's real size. This allows the clip cache to be much more compact, because
no space is wasted for the max. sized clip. This makes use of buflib's ability
to easily manage differently-sized memory chunks by moving them to make free
space.

As an example: for english.voice TALK_PARTIAL_LOAD allocated 288k in advance.
for just 64 clips. With this patch ~70 clips can be stored in a 100k buffer.
This, the memory usage is cut by 2/3 and almost optimal (there's still the
buflib per-alloc cookie overhead).

As a result the TALK_PARTIAL_LOAD buffer is restricted to 100k which still
allows for more clips than previously, on average.

Change-Id: I257654071e9a95770cd6db2c2765f020befce412
2014-02-02 19:40:39 +01:00
Thomas Martitz
dac40fdd60 talk: Add debug menu entry to view statistics about talk engine.
This engine includes voicefile, memory usage and cache
hits/misses for TALK_PARTIAL_LOAD.

Change-Id: I331981ddda39ea30c57b4b74504accb3c556c3b9
2014-02-02 19:40:39 +01:00
Thomas Martitz
57000b513b talk: Make talk_voice_required() local to talk.c
Change-Id: I3a04760d550efab7f011a917597ef29c039b05bd
2014-02-02 19:40:39 +01:00
Thomas Martitz
60dea95cad talk/hwcodec: Do always free the clip buffer in shrink_callback().
This is necessary because when voice is active audio is disabled. But only
audio was able to shrink it's buffer to let other memory allocs succeed.
talk needs to be able to do this too when it owns the audio buffer exclusively.

Change-Id: Idea8ab90da7169f977c0c766cccb42c4fe6d6e81
2014-02-02 19:40:39 +01:00
Thomas Martitz
efc20ec164 talk: When no voice file is loaded don't even attempt to load the clip, it's hopeless.
Change-Id: I420155d7f01ca0ea301c0678ac7245d251d365b0
2014-01-27 10:05:48 +01:00