convert_phonetics: Convert between phonetic representations

Description Usage Arguments Value See Also Examples

View source: R/convert_phonetics.R

Description

Converts between IPA, X-SAMPA and ARPABET (used by the CMU Pronouncing Dictionary)

Usage

1
2
3
4
5
convert_phonetics(
  x,
  from = c("ipa", "xsampa", "arpabet"),
  to = c("ipa", "xsampa", "arpabet")
)

Arguments

x

A phonetic character vector in IPA, X-SAMPA, or ARPABET

from

The phonetic alphabet to convert from

to

The phonetic alphabet to convert to. "sampa" is an accepted alias for "xsampa". "arpa" and "cmu" are accepted aliases for "arpabet".

Value

A character vector the same length as x

See Also

ipa() to convert from IPA

sampa() and xsampa() to convert from X-SAMPA

arpa(), arpabet() and cmu() to convert from ARPABET (CMU)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
convert_phonetics('%hE"loU', from = "xsampa", to = "ipa")
convert_phonetics(c('%hE"loU', "w3`ld"), from = "xsampa", to = "ipa")
convert_phonetics('%hE"loU', from = "xsampa", to = "arpabet")
convert_phonetics(c('%hE"loU', "w3`ld"), from = "xsampa", to = "arpabet")

convert_phonetics('HH EH L OW', from = "arpabet", to = "ipa")
convert_phonetics(c('HH EH L OW', "W ER L D"), from = "arpabet", to = "ipa")
convert_phonetics('HH EH L OW', from = "arpabet", to = "xsampa")
convert_phonetics(c('HH EH L OW', "W ER L D"), from = "arpabet", to = "xsampa")

# `convert_phonetics()` supports raw Unicode input or escaped Unicode sequences
# (\uxxxx), but raw Unicode is not supported in R package documentation,
# hence the ugly examples
convert_phonetics("\\u02cch\\u025b\\'lo\\u028a", from = "ipa", to = "xsampa")
convert_phonetics(
  c("\\u02cch\\u025b\\'lo\\u028a", "w\\u025dld"), from = "ipa", to = "xsampa"
)
convert_phonetics("\\u02cch\\u025b\\'lo\\u028a", from = "ipa", to = "arpabet")
convert_phonetics(
  c("\\u02cch\\u025b\\'lo\\u028a", "w\\u025dld"), from = "ipa", to = "arpabet"
)

Example output

[1] "ˌhɛˈloʊ"
[1] "ˌhɛˈloʊ" "wɝld"   
[1] "HH EH L OW"
Warning message:
In convert_phonetics("%hE\"loU", from = "xsampa", to = "arpabet") :
  Stress is not supported for ARPABET, so stresses were removed.
[1] "HH EH L OW" "W ER L D"  
Warning message:
In convert_phonetics(c("%hE\"loU", "w3`ld"), from = "xsampa", to = "arpabet") :
  Stress is not supported for ARPABET, so stresses were removed.
[1] "hɛloʊ"
[1] "hɛloʊ" "wɝld" 
[1] "hEloU"
[1] "hEloU" "w3`ld"
[1] "\\u02cch\\u025b\\'lo\\u028a"
[1] "\\u02cch\\u025b\\'lo\\u028a" "w\\u025dld"                 
[1] "\\UW 02ccHH \\UW 025B \\'L o\\UW 028a"
[1] "\\UW 02ccHH \\UW 025B \\'L o\\UW 028a"
[2] "W \\UW 025D L D"                      

ipa documentation built on July 2, 2020, 4:14 a.m.