如何在R中大声编程计算机 [英] How to program the computer to speak put loud in R

查看:76
本文介绍了如何在R中大声编程计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在R中有一个返回 a 的脚本,我可以将结果打印为

I have a script in R which returns a and I can print the result as

print(a)

我想要的不是" print()",而是"speak()".以便计算机使用其内部语音"并告诉变量 a 太大了.

Instead of print() I would like something like "speak()". So that the computer uses its "internal voice" and tells what the variable a is out loud.

在R中甚至有可能吗?

(我使用OSX)

(例如,在选择一条文本时可以在OSX中听到语音" - >右键单击 - > Speacal - >开始说话.)

(For example this "voice" can be heard in OSX when selecting a piece of text -> right-click -> speach -> begin speak.)

推荐答案

问题已解决!

@Dason指出,可以使用

As @Dason pointed out, it is possible to do a system call within R using system() and say as command.

system()中的命令必须是一个完整的字符串,以"say"开头,并且可以使用 sprintf().

The command in system() needs to be a complete string beginning with "say" and strings can be put together using sprintf().

示例:

a <- 2+5
b <- sprintf("say The result is %d", a)
system(b, intern = FALSE, ignore.stdout = FALSE, ignore.stderr =
    FALSE, wait = TRUE, input = NULL)

这篇关于如何在R中大声编程计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆