34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
/**
|
|
* speech-units — TTS가 영문 단위 기호를 글자 이름으로 읽는 문제(2026-10-17 "그램을 지라고 읽는다").
|
|
*/
|
|
import { test, describe } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
const { spellUnitsForSpeech: f } = require('../web-ui/js/voice/speech-units.js');
|
|
|
|
describe('spellUnitsForSpeech', () => {
|
|
test('숫자에 붙은 단위를 한글로', () => {
|
|
assert.equal(f('설탕 50g 넣고'), '설탕 50그램 넣고');
|
|
assert.equal(f('72.5kg'), '72.5킬로그램');
|
|
assert.equal(f('15 cm'), '15센티미터');
|
|
assert.equal(f('256GB'), '256기가바이트');
|
|
assert.equal(f('3.4GHz'), '3.4기가헤르츠');
|
|
assert.equal(f('1013hPa'), '1013헥토파스칼');
|
|
assert.equal(f('35㎍/㎥'), '35마이크로그램 퍼 세제곱미터');
|
|
});
|
|
test('복합 단위가 단일 단위보다 먼저', () => {
|
|
assert.equal(f('3.2m/s'), '3.2미터 매 초');
|
|
assert.equal(f('40km/h'), '40킬로미터 매 시');
|
|
assert.equal(f('2.5mm'), '2.5밀리미터');
|
|
});
|
|
test('조사가 붙어도 변환, 영단어·숫자 없는 글자는 그대로', () => {
|
|
assert.equal(f('100m를 달렸다'), '100미터를 달렸다');
|
|
assert.equal(f('5mins left'), '5mins left');
|
|
assert.equal(f('The A team and g'), 'The A team and g');
|
|
});
|
|
test('섭씨·달러', () => {
|
|
assert.equal(f('21.5℃'), '섭씨 21.5도');
|
|
assert.equal(f('$100'), '100달러');
|
|
});
|
|
});
|