fix ipa convert
This commit is contained in:
@@ -390,7 +390,7 @@ export const IPA_MAPPING: { [key: string]: string } = {
|
||||
r: "r",
|
||||
ʀ: "r",
|
||||
ⱱ: "",
|
||||
ɾ: "r",
|
||||
ɾ: "t",
|
||||
ɽ: "r",
|
||||
ɸ: "f",
|
||||
β: "v",
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Timeline } from "echogarden/dist/utilities/Timeline.d.js";
|
||||
import { IPA_MAPPING } from "@/constants";
|
||||
import { useAiCommand } from "@renderer/hooks";
|
||||
import { LoaderIcon } from "lucide-react";
|
||||
import { convertIpaToNormal } from "@/utils";
|
||||
|
||||
export const MediaCaption = () => {
|
||||
const {
|
||||
@@ -353,7 +354,7 @@ export const MediaCaption = () => {
|
||||
{caption.timeline[index].timeline
|
||||
.map((t) =>
|
||||
t.timeline
|
||||
.map((s) => IPA_MAPPING[s.text] || s.text)
|
||||
.map((s) => convertIpaToNormal(s.text))
|
||||
.join("")
|
||||
)
|
||||
.join(" · ")}
|
||||
@@ -382,7 +383,7 @@ export const MediaCaption = () => {
|
||||
{w.timeline
|
||||
.map((t) =>
|
||||
t.timeline
|
||||
.map((s) => IPA_MAPPING[s.text] || s.text)
|
||||
.map((s) => convertIpaToNormal(s.text))
|
||||
.join("")
|
||||
)
|
||||
.join(" · ")}
|
||||
@@ -421,7 +422,7 @@ export const MediaCaption = () => {
|
||||
{word.timeline
|
||||
.map((t) =>
|
||||
t.timeline
|
||||
.map((s) => IPA_MAPPING[s.text] || s.text)
|
||||
.map((s) => convertIpaToNormal(s.text))
|
||||
.join("")
|
||||
)
|
||||
.join(" · ")}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Pitchfinder from "pitchfinder";
|
||||
import { END_OF_SENTENCE_REGEX, MAGIC_TOKEN_REGEX } from "./constants";
|
||||
import { IPA_MAPPING } from "./constants";
|
||||
|
||||
export const extractFrequencies = (props: {
|
||||
peaks: Float32Array;
|
||||
@@ -86,3 +87,15 @@ export const groupTranscription = (
|
||||
|
||||
return groups;
|
||||
};
|
||||
|
||||
export const convertIpaToNormal = (ipa: string) => {
|
||||
const mark = ipa.match(/(\ˈ|ˌ)/);
|
||||
const cleanIpa = ipa.replace(mark ? mark[0] : "", "");
|
||||
|
||||
const converted = IPA_MAPPING[cleanIpa] || cleanIpa;
|
||||
if (mark) {
|
||||
return `${mark[0]}${converted}`;
|
||||
} else {
|
||||
return converted;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user