AttributeError: 'unicode' object has no attribute 'ogg'

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
ElonMuskIsMyDad
Newbie
Posts: 10
Joined: Sun Nov 29, 2020 4:02 pm
Contact:

AttributeError: 'unicode' object has no attribute 'ogg'

#1 Post by ElonMuskIsMyDad »

Hey, everyone,
I've looked everywhere online, but I haven't seen anyone with this specific issue. What's odd is that in the beginning of the game, the music plays just fine, but around line 700, it won't play. The music is copied to the game and audio folder, which had worked for all of the songs. Does the traceback hint at where the problem is? I'm not familiar enough with Ren'Py to know exactly what's going wrong. (Would it help for me to include code? I didn't want to spam with my entire VN, but the problem is so bizarre that I'm not sure what would help.)

Thank you very much!


Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 721, in script
    play music tokyo.ogg
  File "renpy/common/000statements.rpy", line 120, in execute_play_music
    renpy.music.play(_audio_eval(p["file"]),
  File "renpy/common/000statements.rpy", line 32, in _audio_eval
    return eval(expr, locals=store.audio.__dict__)
  File "game/script.rpy", line 721, in <module>
    play music tokyo.ogg
AttributeError: 'unicode' object has no attribute 'ogg'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 721, in script
    play music tokyo.ogg
  File "C:\Users\14076\Downloads\renpy-7.3.5-sdk\renpy\ast.py", line 1949, in execute
    self.call("execute")
  File "C:\Users\14076\Downloads\renpy-7.3.5-sdk\renpy\ast.py", line 1937, in call
    return renpy.statements.call(method, parsed, *args, **kwargs)
  File "C:\Users\14076\Downloads\renpy-7.3.5-sdk\renpy\statements.py", line 277, in call
    return method(parsed, *args, **kwargs)
  File "renpy/common/000statements.rpy", line 120, in execute_play_music
    renpy.music.play(_audio_eval(p["file"]),
  File "renpy/common/000statements.rpy", line 32, in _audio_eval
    return eval(expr, locals=store.audio.__dict__)
  File "C:\Users\14076\Downloads\renpy-7.3.5-sdk\renpy\python.py", line 2059, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "C:\Users\14076\Downloads\renpy-7.3.5-sdk\renpy\python.py", line 2052, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 721, in <module>
    play music tokyo.ogg
AttributeError: 'unicode' object has no attribute 'ogg'

Windows-8-6.2.9200
Ren'Py 7.3.5.606
The Legend of Jessie Cube 1.0
Wed Jan 20 15:58:58 2021

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: AttributeError: 'unicode' object has no attribute 'ogg'

#2 Post by Imperf3kt »

You forgot to wrap your file name in quotation.

Add " to the start and end of the filename.

Code: Select all

play music "tokyo.ogg"
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

ElonMuskIsMyDad
Newbie
Posts: 10
Joined: Sun Nov 29, 2020 4:02 pm
Contact:

Re: AttributeError: 'unicode' object has no attribute 'ogg'

#3 Post by ElonMuskIsMyDad »

Imperf3kt wrote: Wed Jan 20, 2021 5:21 pm You forgot to wrap your file name in quotation.

Add " to the start and end of the filename.

Code: Select all

play music "tokyo.ogg"
How embarrassing. Thank you so much! You really helped me out.

User avatar
PyTom
Ren'Py Creator
Posts: 16093
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: AttributeError: 'unicode' object has no attribute 'ogg'

#4 Post by PyTom »

Adding on to Imperf3kt's answer:

When a sound file is in the game/audio/ directory, and doesn't contain spaces or other special characters, it winds up getting defined in the audio namespace. The play and queue statements try the audio namespace before the default one. So you can just write:

Code: Select all

play music tokyo
in this case. (But it wouldn't work if the name as "tokyo drift.ogg", because of the space.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

ElonMuskIsMyDad
Newbie
Posts: 10
Joined: Sun Nov 29, 2020 4:02 pm
Contact:

Re: AttributeError: 'unicode' object has no attribute 'ogg'

#5 Post by ElonMuskIsMyDad »

Thank you so much!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]