1

我正在尝试使用该playsound模块在 Python 中制作一个简单的节拍器。但是当我运行它时,出现以下错误:

Traceback (most recent call last):   
  File "/run/media/mb/Volume/Dokumente/Coding/Python/Metronom/metronom.py", line 5, in <module>
    playsound("Cowbell.wav")   
  File "/usr/lib/python3.7/site-packages/playsound.py", line 106, in _playsoundNix
    "playbin.set_state returned " + repr(set_result)) 
playsound.PlaysoundException: playbin.set_state returned <enum GST_STATE_CHANGE_FAILURE of type Gst.StateChangeReturn>

如果您阅读文档readxl::read_excel,它包括

range: A cell range to read from, as described in
       cell-specification. Includes typical Excel ranges like
       "B3:D87", possibly including the sheet name like
       "Budget!B2:G14", and more. Interpreted strictly, even if the
       range forces the inclusion of leading or trailing empty rows
       or columns. Takes precedence over 'skip', 'n_max' and
       'sheet'.

虽然很容易假设它必须是一个字符串,但如果你深入?readxl::cell-specification研究 ,它建议你研究cellranger::cell_limits()。在那,它说

cell_limits(ul = c(NA_integer_, NA_integer_), lr = c(NA_integer_,
  NA_integer_), sheet = NA_character_)
...
A value of 'NA' in 'ul' or 'lr' means the corresponding limit is left unspecified.

这表示您可以使用它NA来保持打开状态。

尝试:

A <- read_excel("excell/book.xlsx", sheet="A", range=cellranger::cell_limits(c(3,3)))

其中未指定lr的将右下角打开。

4

1 回答 1

-3
#if its in the same folder as project
playsound('file.mp3')
#somewhere else? then full path (REMEMBER PYTHON USES FORWARDSLASHES /, NOT BACKSLASHES \)
playsound('C:/your/path/to/file.mp3')

另请注意,如果某些文件具有足够高的比特率,它们会引发 playsound 异常(idk 为什么,我想 playsound 无法处理一些高质量的比特率)

于 2020-04-12T02:59:43.313 回答